Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit14cddee

Browse files
committed
Split registration of Win32 deadchild callback to separate function
The next commit will move the internal_forkexec() function to adifferent source file, but it makes sense to keep all the code relatedto the win32 waitpid() emulation in postmaster.c. Split it off to aseparate function now, to make the next commit more mechanical.Reviewed-by: Tristan Partin, Andres FreundDiscussion:https://www.postgresql.org/message-id/7a59b073-5b5b-151e-7ed3-8b01ff7ce9ef@iki.fi
1 parentca108be commit14cddee

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

‎src/backend/postmaster/postmaster.c

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ static void MaybeStartSlotSyncWorker(void);
476476

477477
staticpid_twaitpid(pid_tpid,int*exitstatus,intoptions);
478478
staticvoidWINAPIpgwin32_deadchild_callback(PVOIDlpParameter,BOOLEANTimerOrWaitFired);
479+
staticvoidpgwin32_register_deadchild_callback(HANDLEprocHandle,DWORDprocId);
479480

480481
staticHANDLEwin32ChildQueue;
481482

@@ -4623,7 +4624,6 @@ internal_forkexec(int argc, char *argv[], ClientSocket *client_sock, BackgroundW
46234624
BackendParameters*param;
46244625
SECURITY_ATTRIBUTESsa;
46254626
charparamHandleStr[32];
4626-
win32_deadchild_waitinfo*childinfo;
46274627

46284628
/* Make sure caller set up argv properly */
46294629
Assert(argc >=3);
@@ -4783,26 +4783,10 @@ internal_forkexec(int argc, char *argv[], ClientSocket *client_sock, BackgroundW
47834783
return-1;
47844784
}
47854785

4786-
/*
4787-
* Queue a waiter to signal when this child dies. The wait will be handled
4788-
* automatically by an operating system thread pool. The memory will be
4789-
* freed by a later call to waitpid().
4790-
*/
4791-
childinfo=palloc(sizeof(win32_deadchild_waitinfo));
4792-
childinfo->procHandle=pi.hProcess;
4793-
childinfo->procId=pi.dwProcessId;
4794-
4795-
if (!RegisterWaitForSingleObject(&childinfo->waitHandle,
4796-
pi.hProcess,
4797-
pgwin32_deadchild_callback,
4798-
childinfo,
4799-
INFINITE,
4800-
WT_EXECUTEONLYONCE |WT_EXECUTEINWAITTHREAD))
4801-
ereport(FATAL,
4802-
(errmsg_internal("could not register process for wait: error code %lu",
4803-
GetLastError())));
4786+
/* Set up notification when the child process dies */
4787+
pgwin32_register_deadchild_callback(pi.hProcess,pi.dwProcessId);
48044788

4805-
/* Don't close pi.hProcess here - waitpid() needs access to it */
4789+
/* Don't close pi.hProcess, it's owned by the deadchild callback now */
48064790

48074791
CloseHandle(pi.hThread);
48084792

@@ -6526,6 +6510,32 @@ pgwin32_deadchild_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
65266510
/* Queue SIGCHLD signal. */
65276511
pg_queue_signal(SIGCHLD);
65286512
}
6513+
6514+
/*
6515+
* Queue a waiter to signal when this child dies. The wait will be handled
6516+
* automatically by an operating system thread pool. The memory and the
6517+
* process handle will be freed by a later call to waitpid().
6518+
*/
6519+
staticvoid
6520+
pgwin32_register_deadchild_callback(HANDLEprocHandle,DWORDprocId)
6521+
{
6522+
win32_deadchild_waitinfo*childinfo;
6523+
6524+
childinfo=palloc(sizeof(win32_deadchild_waitinfo));
6525+
childinfo->procHandle=procHandle;
6526+
childinfo->procId=procId;
6527+
6528+
if (!RegisterWaitForSingleObject(&childinfo->waitHandle,
6529+
procHandle,
6530+
pgwin32_deadchild_callback,
6531+
childinfo,
6532+
INFINITE,
6533+
WT_EXECUTEONLYONCE |WT_EXECUTEINWAITTHREAD))
6534+
ereport(FATAL,
6535+
(errmsg_internal("could not register process for wait: error code %lu",
6536+
GetLastError())));
6537+
}
6538+
65296539
#endif/* WIN32 */
65306540

65316541
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp