2 #include "simple-ipc.h"
5 #include "thread-utils.h"
9 #ifndef SUPPORTS_SIMPLE_IPC
11 * This source file should only be compiled when Simple IPC is supported.
12 * See the top-level Makefile.
14 #error SUPPORTS_SIMPLE_IPC not defined
17 static int initialize_pipe_name(const char *path
, wchar_t *wpath
, size_t alloc
)
20 struct strbuf realpath
= STRBUF_INIT
;
22 if (!strbuf_realpath(&realpath
, path
, 0))
25 off
= swprintf(wpath
, alloc
, L
"\\\\.\\pipe\\");
26 if (xutftowcs(wpath
+ off
, realpath
.buf
, alloc
- off
) < 0)
29 /* Handle drive prefix */
30 if (wpath
[off
] && wpath
[off
+ 1] == L
':') {
31 wpath
[off
+ 1] = L
'_';
35 for (; wpath
[off
]; off
++)
36 if (wpath
[off
] == L
'/')
39 strbuf_release(&realpath
);
43 static enum ipc_active_state
get_active_state(wchar_t *pipe_path
)
45 if (WaitNamedPipeW(pipe_path
, NMPWAIT_USE_DEFAULT_WAIT
))
46 return IPC_STATE__LISTENING
;
48 if (GetLastError() == ERROR_SEM_TIMEOUT
)
49 return IPC_STATE__NOT_LISTENING
;
51 if (GetLastError() == ERROR_FILE_NOT_FOUND
)
52 return IPC_STATE__PATH_NOT_FOUND
;
54 trace2_data_intmax("ipc-debug", NULL
, "getstate/waitpipe/gle",
55 (intmax_t)GetLastError());
57 return IPC_STATE__OTHER_ERROR
;
60 enum ipc_active_state
ipc_get_active_state(const char *path
)
62 wchar_t pipe_path
[MAX_PATH
];
64 if (initialize_pipe_name(path
, pipe_path
, ARRAY_SIZE(pipe_path
)) < 0)
65 return IPC_STATE__INVALID_PATH
;
67 return get_active_state(pipe_path
);
70 #define WAIT_STEP_MS (50)
72 static enum ipc_active_state
connect_to_server(
75 const struct ipc_client_connect_options
*options
,
78 DWORD t_start_ms
, t_waited_ms
;
80 HANDLE hPipe
= INVALID_HANDLE_VALUE
;
81 DWORD mode
= PIPE_READMODE_BYTE
;
87 hPipe
= CreateFileW(wpath
, GENERIC_READ
| GENERIC_WRITE
,
88 0, NULL
, OPEN_EXISTING
, 0, NULL
);
89 if (hPipe
!= INVALID_HANDLE_VALUE
)
95 case ERROR_FILE_NOT_FOUND
:
96 if (!options
->wait_if_not_found
)
97 return IPC_STATE__PATH_NOT_FOUND
;
99 return IPC_STATE__PATH_NOT_FOUND
;
101 step_ms
= (timeout_ms
< WAIT_STEP_MS
) ?
102 timeout_ms
: WAIT_STEP_MS
;
103 sleep_millisec(step_ms
);
105 timeout_ms
-= step_ms
;
106 break; /* try again */
108 case ERROR_PIPE_BUSY
:
109 if (!options
->wait_if_busy
)
110 return IPC_STATE__NOT_LISTENING
;
112 return IPC_STATE__NOT_LISTENING
;
114 t_start_ms
= (DWORD
)(getnanotime() / 1000000);
116 if (!WaitNamedPipeW(wpath
, timeout_ms
)) {
117 DWORD gleWait
= GetLastError();
119 if (gleWait
== ERROR_SEM_TIMEOUT
)
120 return IPC_STATE__NOT_LISTENING
;
122 trace2_data_intmax("ipc-debug", NULL
,
123 "connect/waitpipe/gle",
126 return IPC_STATE__OTHER_ERROR
;
130 * A pipe server instance became available.
131 * Race other client processes to connect to
134 * But first decrement our overall timeout so
135 * that we don't starve if we keep losing the
136 * race. But also guard against special
137 * NPMWAIT_ values (0 and -1).
139 t_waited_ms
= (DWORD
)(getnanotime() / 1000000) - t_start_ms
;
140 if (t_waited_ms
< timeout_ms
)
141 timeout_ms
-= t_waited_ms
;
144 break; /* try again */
147 trace2_data_intmax("ipc-debug", NULL
,
148 "connect/createfile/gle",
151 return IPC_STATE__OTHER_ERROR
;
155 if (!SetNamedPipeHandleState(hPipe
, &mode
, NULL
, NULL
)) {
156 gle
= GetLastError();
157 trace2_data_intmax("ipc-debug", NULL
,
158 "connect/setpipestate/gle",
162 return IPC_STATE__OTHER_ERROR
;
165 *pfd
= _open_osfhandle((intptr_t)hPipe
, O_RDWR
|O_BINARY
);
167 gle
= GetLastError();
168 trace2_data_intmax("ipc-debug", NULL
,
169 "connect/openosfhandle/gle",
173 return IPC_STATE__OTHER_ERROR
;
176 /* fd now owns hPipe */
178 return IPC_STATE__LISTENING
;
182 * The default connection timeout for Windows clients.
184 * This is not currently part of the ipc_ API (nor the config settings)
185 * because of differences between Windows and other platforms.
187 * This value was chosen at random.
189 #define WINDOWS_CONNECTION_TIMEOUT_MS (30000)
191 enum ipc_active_state
ipc_client_try_connect(
193 const struct ipc_client_connect_options
*options
,
194 struct ipc_client_connection
**p_connection
)
196 wchar_t wpath
[MAX_PATH
];
197 enum ipc_active_state state
= IPC_STATE__OTHER_ERROR
;
200 *p_connection
= NULL
;
202 trace2_region_enter("ipc-client", "try-connect", NULL
);
203 trace2_data_string("ipc-client", NULL
, "try-connect/path", path
);
205 if (initialize_pipe_name(path
, wpath
, ARRAY_SIZE(wpath
)) < 0)
206 state
= IPC_STATE__INVALID_PATH
;
208 state
= connect_to_server(wpath
, WINDOWS_CONNECTION_TIMEOUT_MS
,
211 trace2_data_intmax("ipc-client", NULL
, "try-connect/state",
213 trace2_region_leave("ipc-client", "try-connect", NULL
);
215 if (state
== IPC_STATE__LISTENING
) {
216 (*p_connection
) = xcalloc(1, sizeof(struct ipc_client_connection
));
217 (*p_connection
)->fd
= fd
;
223 void ipc_client_close_connection(struct ipc_client_connection
*connection
)
228 if (connection
->fd
!= -1)
229 close(connection
->fd
);
234 int ipc_client_send_command_to_connection(
235 struct ipc_client_connection
*connection
,
236 const char *message
, size_t message_len
,
237 struct strbuf
*answer
)
241 strbuf_setlen(answer
, 0);
243 trace2_region_enter("ipc-client", "send-command", NULL
);
245 if (write_packetized_from_buf_no_flush(message
, message_len
,
246 connection
->fd
) < 0 ||
247 packet_flush_gently(connection
->fd
) < 0) {
248 ret
= error(_("could not send IPC command"));
252 FlushFileBuffers((HANDLE
)_get_osfhandle(connection
->fd
));
254 if (read_packetized_to_strbuf(
255 connection
->fd
, answer
,
256 PACKET_READ_GENTLE_ON_EOF
| PACKET_READ_GENTLE_ON_READ_ERROR
) < 0) {
257 ret
= error(_("could not read IPC response"));
262 trace2_region_leave("ipc-client", "send-command", NULL
);
266 int ipc_client_send_command(const char *path
,
267 const struct ipc_client_connect_options
*options
,
268 const char *message
, size_t message_len
,
269 struct strbuf
*response
)
272 enum ipc_active_state state
;
273 struct ipc_client_connection
*connection
= NULL
;
275 state
= ipc_client_try_connect(path
, options
, &connection
);
277 if (state
!= IPC_STATE__LISTENING
)
280 ret
= ipc_client_send_command_to_connection(connection
,
281 message
, message_len
,
284 ipc_client_close_connection(connection
);
290 * Duplicate the given pipe handle and wrap it in a file descriptor so
291 * that we can use pkt-line on it.
293 static int dup_fd_from_pipe(const HANDLE pipe
)
295 HANDLE process
= GetCurrentProcess();
299 if (!DuplicateHandle(process
, pipe
, process
, &handle
, 0, FALSE
,
300 DUPLICATE_SAME_ACCESS
)) {
301 errno
= err_win_to_posix(GetLastError());
305 fd
= _open_osfhandle((intptr_t)handle
, O_RDWR
|O_BINARY
);
307 errno
= err_win_to_posix(GetLastError());
313 * `handle` is now owned by `fd` and will be automatically closed
314 * when the descriptor is closed.
321 * Magic numbers used to annotate callback instance data.
322 * These are used to help guard against accidentally passing the
323 * wrong instance data across multiple levels of callbacks (which
324 * is easy to do if there are `void*` arguments).
327 MAGIC_SERVER_REPLY_DATA
,
328 MAGIC_SERVER_THREAD_DATA
,
332 struct ipc_server_reply_data
{
335 struct ipc_server_thread_data
*server_thread_data
;
338 struct ipc_server_thread_data
{
340 struct ipc_server_thread_data
*next_thread
;
341 struct ipc_server_data
*server_data
;
342 pthread_t pthread_id
;
347 * On Windows, the conceptual "ipc-server" is implemented as a pool of
348 * n idential/peer "server-thread" threads. That is, there is no
349 * hierarchy of threads; and therefore no controller thread managing
350 * the pool. Each thread has an independent handle to the named pipe,
351 * receives incoming connections, processes the client, and re-uses
352 * the pipe for the next client connection.
354 * Therefore, the "ipc-server" only needs to maintain a list of the
355 * spawned threads for eventual "join" purposes.
357 * A single "stop-event" is visible to all of the server threads to
358 * tell them to shutdown (when idle).
360 struct ipc_server_data
{
362 ipc_server_application_cb
*application_cb
;
363 void *application_data
;
364 struct strbuf buf_path
;
365 wchar_t wpath
[MAX_PATH
];
367 HANDLE hEventStopRequested
;
368 struct ipc_server_thread_data
*thread_list
;
372 enum connect_result
{
380 static enum connect_result
queue_overlapped_connect(
381 struct ipc_server_thread_data
*server_thread_data
,
384 if (ConnectNamedPipe(server_thread_data
->hPipe
, lpo
))
387 switch (GetLastError()) {
388 case ERROR_IO_PENDING
:
389 return CR_CONNECT_PENDING
;
391 case ERROR_PIPE_CONNECTED
:
392 SetEvent(lpo
->hEvent
);
400 error(_("ConnectNamedPipe failed for '%s' (%lu)"),
401 server_thread_data
->server_data
->buf_path
.buf
,
403 return CR_CONNECT_ERROR
;
407 * Use Windows Overlapped IO to wait for a connection or for our event
410 static enum connect_result
wait_for_connection(
411 struct ipc_server_thread_data
*server_thread_data
,
414 enum connect_result r
;
415 HANDLE waitHandles
[2];
418 r
= queue_overlapped_connect(server_thread_data
, lpo
);
419 if (r
!= CR_CONNECT_PENDING
)
422 waitHandles
[0] = server_thread_data
->server_data
->hEventStopRequested
;
423 waitHandles
[1] = lpo
->hEvent
;
425 dwWaitResult
= WaitForMultipleObjects(2, waitHandles
, FALSE
, INFINITE
);
426 switch (dwWaitResult
) {
427 case WAIT_OBJECT_0
+ 0:
430 case WAIT_OBJECT_0
+ 1:
431 ResetEvent(lpo
->hEvent
);
435 return CR_WAIT_ERROR
;
440 * Forward declare our reply callback function so that any compiler
441 * errors are reported when we actually define the function (in addition
442 * to any errors reported when we try to pass this callback function as
443 * a parameter in a function call). The former are easier to understand.
445 static ipc_server_reply_cb do_io_reply_callback
;
448 * Relay application's response message to the client process.
449 * (We do not flush at this point because we allow the caller
450 * to chunk data to the client thru us.)
452 static int do_io_reply_callback(struct ipc_server_reply_data
*reply_data
,
453 const char *response
, size_t response_len
)
455 if (reply_data
->magic
!= MAGIC_SERVER_REPLY_DATA
)
456 BUG("reply_cb called with wrong instance data");
458 return write_packetized_from_buf_no_flush(response
, response_len
,
463 * Receive the request/command from the client and pass it to the
464 * registered request-callback. The request-callback will compose
465 * a response and call our reply-callback to send it to the client.
467 * Simple-IPC only contains one round trip, so we flush and close
468 * here after the response.
470 static int do_io(struct ipc_server_thread_data
*server_thread_data
)
472 struct strbuf buf
= STRBUF_INIT
;
473 struct ipc_server_reply_data reply_data
;
476 reply_data
.magic
= MAGIC_SERVER_REPLY_DATA
;
477 reply_data
.server_thread_data
= server_thread_data
;
479 reply_data
.fd
= dup_fd_from_pipe(server_thread_data
->hPipe
);
480 if (reply_data
.fd
< 0)
481 return error(_("could not create fd from pipe for '%s'"),
482 server_thread_data
->server_data
->buf_path
.buf
);
484 ret
= read_packetized_to_strbuf(
486 PACKET_READ_GENTLE_ON_EOF
| PACKET_READ_GENTLE_ON_READ_ERROR
);
488 ret
= server_thread_data
->server_data
->application_cb(
489 server_thread_data
->server_data
->application_data
,
490 buf
.buf
, buf
.len
, do_io_reply_callback
, &reply_data
);
492 packet_flush_gently(reply_data
.fd
);
494 FlushFileBuffers((HANDLE
)_get_osfhandle((reply_data
.fd
)));
498 * The client probably disconnected/shutdown before it
499 * could send a well-formed message. Ignore it.
503 strbuf_release(&buf
);
504 close(reply_data
.fd
);
510 * Handle IPC request and response with this connected client. And reset
511 * the pipe to prepare for the next client.
513 static int use_connection(struct ipc_server_thread_data
*server_thread_data
)
517 ret
= do_io(server_thread_data
);
519 FlushFileBuffers(server_thread_data
->hPipe
);
520 DisconnectNamedPipe(server_thread_data
->hPipe
);
526 * Thread proc for an IPC server worker thread. It handles a series of
527 * connections from clients. It cleans and reuses the hPipe between each
530 static void *server_thread_proc(void *_server_thread_data
)
532 struct ipc_server_thread_data
*server_thread_data
= _server_thread_data
;
533 HANDLE hEventConnected
= INVALID_HANDLE_VALUE
;
535 enum connect_result cr
;
538 assert(server_thread_data
->hPipe
!= INVALID_HANDLE_VALUE
);
540 trace2_thread_start("ipc-server");
541 trace2_data_string("ipc-server", NULL
, "pipe",
542 server_thread_data
->server_data
->buf_path
.buf
);
544 hEventConnected
= CreateEventW(NULL
, TRUE
, FALSE
, NULL
);
546 memset(&oConnect
, 0, sizeof(oConnect
));
547 oConnect
.hEvent
= hEventConnected
;
550 cr
= wait_for_connection(server_thread_data
, &oConnect
);
557 ret
= use_connection(server_thread_data
);
558 if (ret
== SIMPLE_IPC_QUIT
) {
559 ipc_server_stop_async(
560 server_thread_data
->server_data
);
565 * Ignore (transient) IO errors with this
566 * client and reset for the next client.
571 case CR_CONNECT_PENDING
:
572 /* By construction, this should not happen. */
573 BUG("ipc-server[%s]: unexpeced CR_CONNECT_PENDING",
574 server_thread_data
->server_data
->buf_path
.buf
);
576 case CR_CONNECT_ERROR
:
579 * Ignore these theoretical errors.
581 DisconnectNamedPipe(server_thread_data
->hPipe
);
585 BUG("unandled case after wait_for_connection");
590 CloseHandle(server_thread_data
->hPipe
);
591 CloseHandle(hEventConnected
);
593 trace2_thread_exit();
598 * We need to build a Windows "SECURITY_ATTRIBUTES" object and use it
599 * to apply an ACL when we create the initial instance of the Named
600 * Pipe. The construction is somewhat involved and consists of
601 * several sequential steps and intermediate objects.
603 * We use this structure to hold these intermediate pointers so that
604 * we can free them as a group. (It is unclear from the docs whether
605 * some of these intermediate pointers can be freed before we are
606 * finished using the "lpSA" member.)
612 PSECURITY_DESCRIPTOR pSD
;
613 LPSECURITY_ATTRIBUTES lpSA
;
616 static void init_sa(struct my_sa_data
*d
)
618 memset(d
, 0, sizeof(*d
));
621 static void release_sa(struct my_sa_data
*d
)
624 FreeSid(d
->pEveryoneSID
);
632 memset(d
, 0, sizeof(*d
));
636 * Create SECURITY_ATTRIBUTES to apply to the initial named pipe. The
637 * creator of the first server instance gets to set the ACLs on it.
639 * We allow the well-known group `EVERYONE` to have read+write access
640 * to the named pipe so that clients can send queries to the daemon
641 * and receive the response.
643 * Normally, this is not necessary since the daemon is usually
644 * automatically started by a foreground command like `git status`,
645 * but in those cases where an elevated Git command started the daemon
646 * (such that the daemon itself runs with elevation), we need to add
647 * the ACL so that non-elevated commands can write to it.
649 * The following document was helpful:
650 * https://docs.microsoft.com/en-us/windows/win32/secauthz/creating-a-security-descriptor-for-a-new-object-in-c--
652 * Returns d->lpSA set to a SA or NULL.
654 static LPSECURITY_ATTRIBUTES
get_sa(struct my_sa_data
*d
)
656 SID_IDENTIFIER_AUTHORITY sid_auth_world
= SECURITY_WORLD_SID_AUTHORITY
;
658 EXPLICIT_ACCESS ea
[NR_EA
];
661 if (!AllocateAndInitializeSid(&sid_auth_world
, 1,
662 SECURITY_WORLD_RID
, 0,0,0,0,0,0,0,
664 DWORD gle
= GetLastError();
665 trace2_data_intmax("ipc-debug", NULL
, "alloc-world-sid/gle",
670 memset(ea
, 0, NR_EA
* sizeof(EXPLICIT_ACCESS
));
672 ea
[0].grfAccessPermissions
= GENERIC_READ
| GENERIC_WRITE
;
673 ea
[0].grfAccessMode
= SET_ACCESS
;
674 ea
[0].grfInheritance
= NO_INHERITANCE
;
675 ea
[0].Trustee
.MultipleTrusteeOperation
= NO_MULTIPLE_TRUSTEE
;
676 ea
[0].Trustee
.TrusteeForm
= TRUSTEE_IS_SID
;
677 ea
[0].Trustee
.TrusteeType
= TRUSTEE_IS_WELL_KNOWN_GROUP
;
678 ea
[0].Trustee
.ptstrName
= (LPTSTR
)d
->pEveryoneSID
;
680 dwResult
= SetEntriesInAcl(NR_EA
, ea
, NULL
, &d
->pACL
);
681 if (dwResult
!= ERROR_SUCCESS
) {
682 DWORD gle
= GetLastError();
683 trace2_data_intmax("ipc-debug", NULL
, "set-acl-entry/gle",
685 trace2_data_intmax("ipc-debug", NULL
, "set-acl-entry/dw",
690 d
->pSD
= (PSECURITY_DESCRIPTOR
)LocalAlloc(
691 LPTR
, SECURITY_DESCRIPTOR_MIN_LENGTH
);
692 if (!InitializeSecurityDescriptor(d
->pSD
, SECURITY_DESCRIPTOR_REVISION
)) {
693 DWORD gle
= GetLastError();
694 trace2_data_intmax("ipc-debug", NULL
, "init-sd/gle", (intmax_t)gle
);
698 if (!SetSecurityDescriptorDacl(d
->pSD
, TRUE
, d
->pACL
, FALSE
)) {
699 DWORD gle
= GetLastError();
700 trace2_data_intmax("ipc-debug", NULL
, "set-sd-dacl/gle", (intmax_t)gle
);
704 d
->lpSA
= (LPSECURITY_ATTRIBUTES
)LocalAlloc(LPTR
, sizeof(SECURITY_ATTRIBUTES
));
705 d
->lpSA
->nLength
= sizeof(SECURITY_ATTRIBUTES
);
706 d
->lpSA
->lpSecurityDescriptor
= d
->pSD
;
707 d
->lpSA
->bInheritHandle
= FALSE
;
716 static HANDLE
create_new_pipe(wchar_t *wpath
, int is_first
)
719 DWORD dwOpenMode
, dwPipeMode
;
720 struct my_sa_data my_sa_data
;
722 init_sa(&my_sa_data
);
724 dwOpenMode
= PIPE_ACCESS_INBOUND
| PIPE_ACCESS_OUTBOUND
|
725 FILE_FLAG_OVERLAPPED
;
727 dwPipeMode
= PIPE_TYPE_MESSAGE
| PIPE_READMODE_BYTE
| PIPE_WAIT
|
728 PIPE_REJECT_REMOTE_CLIENTS
;
731 dwOpenMode
|= FILE_FLAG_FIRST_PIPE_INSTANCE
;
734 * On Windows, the first server pipe instance gets to
735 * set the ACL / Security Attributes on the named
736 * pipe; subsequent instances inherit and cannot
742 hPipe
= CreateNamedPipeW(wpath
, dwOpenMode
, dwPipeMode
,
743 PIPE_UNLIMITED_INSTANCES
, 1024, 1024, 0,
746 release_sa(&my_sa_data
);
751 int ipc_server_run_async(struct ipc_server_data
**returned_server_data
,
752 const char *path
, const struct ipc_server_opts
*opts
,
753 ipc_server_application_cb
*application_cb
,
754 void *application_data
)
756 struct ipc_server_data
*server_data
;
757 wchar_t wpath
[MAX_PATH
];
758 HANDLE hPipeFirst
= INVALID_HANDLE_VALUE
;
761 int nr_threads
= opts
->nr_threads
;
763 *returned_server_data
= NULL
;
765 ret
= initialize_pipe_name(path
, wpath
, ARRAY_SIZE(wpath
));
771 hPipeFirst
= create_new_pipe(wpath
, 1);
772 if (hPipeFirst
== INVALID_HANDLE_VALUE
) {
777 server_data
= xcalloc(1, sizeof(*server_data
));
778 server_data
->magic
= MAGIC_SERVER_DATA
;
779 server_data
->application_cb
= application_cb
;
780 server_data
->application_data
= application_data
;
781 server_data
->hEventStopRequested
= CreateEvent(NULL
, TRUE
, FALSE
, NULL
);
782 strbuf_init(&server_data
->buf_path
, 0);
783 strbuf_addstr(&server_data
->buf_path
, path
);
784 wcscpy(server_data
->wpath
, wpath
);
789 for (k
= 0; k
< nr_threads
; k
++) {
790 struct ipc_server_thread_data
*std
;
792 std
= xcalloc(1, sizeof(*std
));
793 std
->magic
= MAGIC_SERVER_THREAD_DATA
;
794 std
->server_data
= server_data
;
795 std
->hPipe
= INVALID_HANDLE_VALUE
;
797 std
->hPipe
= (k
== 0)
799 : create_new_pipe(server_data
->wpath
, 0);
801 if (std
->hPipe
== INVALID_HANDLE_VALUE
) {
803 * If we've reached a pipe instance limit for
804 * this path, just use fewer threads.
810 if (pthread_create(&std
->pthread_id
, NULL
,
811 server_thread_proc
, std
)) {
813 * Likewise, if we're out of threads, just use
814 * fewer threads than requested.
816 * However, we just give up if we can't even get
817 * one thread. This should not happen.
820 die(_("could not start thread[0] for '%s'"),
823 CloseHandle(std
->hPipe
);
828 std
->next_thread
= server_data
->thread_list
;
829 server_data
->thread_list
= std
;
832 *returned_server_data
= server_data
;
836 int ipc_server_stop_async(struct ipc_server_data
*server_data
)
842 * Gently tell all of the ipc_server threads to shutdown.
843 * This will be seen the next time they are idle (and waiting
846 * We DO NOT attempt to force them to drop an active connection.
848 SetEvent(server_data
->hEventStopRequested
);
852 int ipc_server_await(struct ipc_server_data
*server_data
)
859 dwWaitResult
= WaitForSingleObject(server_data
->hEventStopRequested
, INFINITE
);
860 if (dwWaitResult
!= WAIT_OBJECT_0
)
861 return error(_("wait for hEvent failed for '%s'"),
862 server_data
->buf_path
.buf
);
864 while (server_data
->thread_list
) {
865 struct ipc_server_thread_data
*std
= server_data
->thread_list
;
867 pthread_join(std
->pthread_id
, NULL
);
869 server_data
->thread_list
= std
->next_thread
;
873 server_data
->is_stopped
= 1;
878 void ipc_server_free(struct ipc_server_data
*server_data
)
883 if (!server_data
->is_stopped
)
884 BUG("cannot free ipc-server while running for '%s'",
885 server_data
->buf_path
.buf
);
887 strbuf_release(&server_data
->buf_path
);
889 if (server_data
->hEventStopRequested
!= INVALID_HANDLE_VALUE
)
890 CloseHandle(server_data
->hEventStopRequested
);
892 while (server_data
->thread_list
) {
893 struct ipc_server_thread_data
*std
= server_data
->thread_list
;
895 server_data
->thread_list
= std
->next_thread
;