@@ -825,29 +825,34 @@ CreateLockFile(const char *filename, bool amPostmaster,
825825 */
826826if (isDDLock )
827827{
828- char * ptr ;
828+ char * ptr = NULL ;
829829unsigned long id1 ,
830830id2 ;
831+ int lineno ;
831832
832- ptr = strchr (buffer ,'\n' );
833- if (ptr != NULL &&
834- (ptr = strchr (ptr + 1 ,'\n' ))!= NULL )
833+ for (lineno = 1 ;lineno <=4 ;lineno ++ )
835834{
836- ptr ++ ;
837- if (sscanf (ptr ,"%lu %lu" ,& id1 ,& id2 )== 2 )
835+ if ((ptr = strchr (ptr ,'\n' ))== NULL )
838836{
839- if (PGSharedMemoryIsInUse (id1 ,id2 ))
840- ereport (FATAL ,
841- (errcode (ERRCODE_LOCK_FILE_EXISTS ),
842- errmsg ("pre-existing shared memory block "
843- "(key %lu, ID %lu) is still in use" ,
844- id1 ,id2 ),
845- errhint ("If you're sure there are no old "
846- "server processes still running, remove "
847- "the shared memory block "
848- "or just delete the file \"%s\"." ,
849- filename )));
837+ elog (LOG ,"bogus data in \"%s\"" ,DIRECTORY_LOCK_FILE );
838+ break ;
850839}
840+ ptr ++ ;
841+ }
842+
843+ if (ptr && sscanf (ptr ,"%lu %lu" ,& id1 ,& id2 )== 2 )
844+ {
845+ if (PGSharedMemoryIsInUse (id1 ,id2 ))
846+ ereport (FATAL ,
847+ (errcode (ERRCODE_LOCK_FILE_EXISTS ),
848+ errmsg ("pre-existing shared memory block "
849+ "(key %lu, ID %lu) is still in use" ,
850+ id1 ,id2 ),
851+ errhint ("If you're sure there are no old "
852+ "server processes still running, remove "
853+ "the shared memory block "
854+ "or just delete the file \"%s\"." ,
855+ filename )));
851856}
852857}
853858