Added include protection for unistd.h and sys/time.h.
[wine] / scheduler / client.c
1 /*
2  * Client part of the client/server communication
3  *
4  * Copyright (C) 1998 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <assert.h>
25 #include <ctype.h>
26 #include <errno.h>
27 #include <fcntl.h>
28 #ifdef HAVE_PWD_H
29 # include <pwd.h>
30 #endif
31 #include <signal.h>
32 #include <stdio.h>
33 #include <string.h>
34 #include <sys/types.h>
35 #ifdef HAVE_SYS_SOCKET_H
36 # include <sys/socket.h>
37 #endif
38 #ifdef HAVE_SYS_WAIT_H
39 #include <sys/wait.h>
40 #endif
41 #include <sys/un.h>
42 #ifdef HAVE_SYS_MMAN_H
43 #include <sys/mman.h>
44 #endif
45 #include <sys/stat.h>
46 #include <sys/uio.h>
47 #ifdef HAVE_UNISTD_H
48 # include <unistd.h>
49 #endif
50 #include <stdarg.h>
51
52 #include "thread.h"
53 #include "wine/library.h"
54 #include "wine/server.h"
55 #include "winerror.h"
56 #include "options.h"
57
58 /* Some versions of glibc don't define this */
59 #ifndef SCM_RIGHTS
60 #define SCM_RIGHTS 1
61 #endif
62
63 #define SOCKETNAME "socket"        /* name of the socket file */
64 #define LOCKNAME   "lock"          /* name of the lock file */
65
66 #ifndef HAVE_MSGHDR_ACCRIGHTS
67 /* data structure used to pass an fd with sendmsg/recvmsg */
68 struct cmsg_fd
69 {
70     int len;   /* sizeof structure */
71     int level; /* SOL_SOCKET */
72     int type;  /* SCM_RIGHTS */
73     int fd;    /* fd to pass */
74 };
75 #endif  /* HAVE_MSGHDR_ACCRIGHTS */
76
77 static void *boot_thread_id;
78 static sigset_t block_set;  /* signals to block during server calls */
79 static int fd_socket;  /* socket to exchange file descriptors with the server */
80
81 #ifdef __GNUC__
82 static void fatal_error( const char *err, ... ) __attribute__((noreturn, format(printf,1,2)));
83 static void fatal_perror( const char *err, ... ) __attribute__((noreturn, format(printf,1,2)));
84 static void server_connect_error( const char *serverdir ) __attribute__((noreturn));
85 #endif
86
87 /* die on a fatal error; use only during initialization */
88 static void fatal_error( const char *err, ... )
89 {
90     va_list args;
91
92     va_start( args, err );
93     fprintf( stderr, "wine: " );
94     vfprintf( stderr, err, args );
95     va_end( args );
96     exit(1);
97 }
98
99 /* die on a fatal error; use only during initialization */
100 static void fatal_perror( const char *err, ... )
101 {
102     va_list args;
103
104     va_start( args, err );
105     fprintf( stderr, "wine: " );
106     vfprintf( stderr, err, args );
107     perror( " " );
108     va_end( args );
109     exit(1);
110 }
111
112 /***********************************************************************
113  *           server_protocol_error
114  */
115 void server_protocol_error( const char *err, ... )
116 {
117     va_list args;
118
119     va_start( args, err );
120     fprintf( stderr, "wine client error:%p: ", NtCurrentTeb()->tid );
121     vfprintf( stderr, err, args );
122     va_end( args );
123     SYSDEPS_AbortThread(1);
124 }
125
126
127 /***********************************************************************
128  *           server_protocol_perror
129  */
130 void server_protocol_perror( const char *err )
131 {
132     fprintf( stderr, "wine client error:%p: ", NtCurrentTeb()->tid );
133     perror( err );
134     SYSDEPS_AbortThread(1);
135 }
136
137
138 /***********************************************************************
139  *           send_request
140  *
141  * Send a request to the server.
142  */
143 static void send_request( const struct __server_request_info *req )
144 {
145     int i, ret;
146
147     if (!req->u.req.request_header.request_size)
148     {
149         if ((ret = write( NtCurrentTeb()->request_fd, &req->u.req,
150                           sizeof(req->u.req) )) == sizeof(req->u.req)) return;
151
152     }
153     else
154     {
155         struct iovec vec[__SERVER_MAX_DATA+1];
156
157         vec[0].iov_base = (void *)&req->u.req;
158         vec[0].iov_len = sizeof(req->u.req);
159         for (i = 0; i < req->data_count; i++)
160         {
161             vec[i+1].iov_base = (void *)req->data[i].ptr;
162             vec[i+1].iov_len = req->data[i].size;
163         }
164         if ((ret = writev( NtCurrentTeb()->request_fd, vec, i+1 )) ==
165             req->u.req.request_header.request_size + sizeof(req->u.req)) return;
166     }
167
168     if (ret >= 0) server_protocol_error( "partial write %d\n", ret );
169     if (errno == EPIPE) SYSDEPS_AbortThread(0);
170     server_protocol_perror( "sendmsg" );
171 }
172
173
174 /***********************************************************************
175  *           read_reply_data
176  *
177  * Read data from the reply buffer; helper for wait_reply.
178  */
179 static void read_reply_data( void *buffer, size_t size )
180 {
181     int ret;
182
183     for (;;)
184     {
185         if ((ret = read( NtCurrentTeb()->reply_fd, buffer, size )) > 0)
186         {
187             if (!(size -= ret)) return;
188             buffer = (char *)buffer + ret;
189             continue;
190         }
191         if (!ret) break;
192         if (errno == EINTR) continue;
193         if (errno == EPIPE) break;
194         server_protocol_perror("read");
195     }
196     /* the server closed the connection; time to die... */
197     SYSDEPS_AbortThread(0);
198 }
199
200
201 /***********************************************************************
202  *           wait_reply
203  *
204  * Wait for a reply from the server.
205  */
206 inline static void wait_reply( struct __server_request_info *req )
207 {
208     read_reply_data( &req->u.reply, sizeof(req->u.reply) );
209     if (req->u.reply.reply_header.reply_size)
210         read_reply_data( req->reply_data, req->u.reply.reply_header.reply_size );
211 }
212
213
214 /***********************************************************************
215  *           wine_server_call (NTDLL.@)
216  *
217  * Perform a server call.
218  */
219 unsigned int wine_server_call( void *req_ptr )
220 {
221     struct __server_request_info * const req = req_ptr;
222     sigset_t old_set;
223
224     memset( (char *)&req->u.req + req->size, 0, sizeof(req->u.req) - req->size );
225     sigprocmask( SIG_BLOCK, &block_set, &old_set );
226     send_request( req );
227     wait_reply( req );
228     sigprocmask( SIG_SETMASK, &old_set, NULL );
229     return req->u.reply.reply_header.error;
230 }
231
232
233 /***********************************************************************
234  *           wine_server_send_fd
235  *
236  * Send a file descriptor to the server.
237  */
238 void wine_server_send_fd( int fd )
239 {
240 #ifndef HAVE_MSGHDR_ACCRIGHTS
241     struct cmsg_fd cmsg;
242 #endif
243     struct send_fd data;
244     struct msghdr msghdr;
245     struct iovec vec;
246     int ret;
247
248     vec.iov_base = (void *)&data;
249     vec.iov_len  = sizeof(data);
250
251     msghdr.msg_name    = NULL;
252     msghdr.msg_namelen = 0;
253     msghdr.msg_iov     = &vec;
254     msghdr.msg_iovlen  = 1;
255
256 #ifdef HAVE_MSGHDR_ACCRIGHTS
257     msghdr.msg_accrights    = (void *)&fd;
258     msghdr.msg_accrightslen = sizeof(fd);
259 #else  /* HAVE_MSGHDR_ACCRIGHTS */
260     cmsg.len   = sizeof(cmsg);
261     cmsg.level = SOL_SOCKET;
262     cmsg.type  = SCM_RIGHTS;
263     cmsg.fd    = fd;
264     msghdr.msg_control    = &cmsg;
265     msghdr.msg_controllen = sizeof(cmsg);
266     msghdr.msg_flags      = 0;
267 #endif  /* HAVE_MSGHDR_ACCRIGHTS */
268
269     data.tid = (void *)GetCurrentThreadId();
270     data.fd  = fd;
271
272     for (;;)
273     {
274         if ((ret = sendmsg( fd_socket, &msghdr, 0 )) == sizeof(data)) return;
275         if (ret >= 0) server_protocol_error( "partial write %d\n", ret );
276         if (errno == EINTR) continue;
277         if (errno == EPIPE) SYSDEPS_AbortThread(0);
278         server_protocol_perror( "sendmsg" );
279     }
280 }
281
282
283 /***********************************************************************
284  *           receive_fd
285  *
286  * Receive a file descriptor passed from the server.
287  */
288 static int receive_fd( obj_handle_t *handle )
289 {
290     struct iovec vec;
291     int ret, fd;
292
293 #ifdef HAVE_MSGHDR_ACCRIGHTS
294     struct msghdr msghdr;
295
296     fd = -1;
297     msghdr.msg_accrights    = (void *)&fd;
298     msghdr.msg_accrightslen = sizeof(fd);
299 #else  /* HAVE_MSGHDR_ACCRIGHTS */
300     struct msghdr msghdr;
301     struct cmsg_fd cmsg;
302
303     cmsg.len   = sizeof(cmsg);
304     cmsg.level = SOL_SOCKET;
305     cmsg.type  = SCM_RIGHTS;
306     cmsg.fd    = -1;
307     msghdr.msg_control    = &cmsg;
308     msghdr.msg_controllen = sizeof(cmsg);
309     msghdr.msg_flags      = 0;
310 #endif  /* HAVE_MSGHDR_ACCRIGHTS */
311
312     msghdr.msg_name    = NULL;
313     msghdr.msg_namelen = 0;
314     msghdr.msg_iov     = &vec;
315     msghdr.msg_iovlen  = 1;
316     vec.iov_base = (void *)handle;
317     vec.iov_len  = sizeof(*handle);
318
319     for (;;)
320     {
321         if ((ret = recvmsg( fd_socket, &msghdr, 0 )) > 0)
322         {
323 #ifndef HAVE_MSGHDR_ACCRIGHTS
324             fd = cmsg.fd;
325 #endif
326             if (fd == -1) server_protocol_error( "no fd received for handle %d\n", *handle );
327             fcntl( fd, F_SETFD, 1 ); /* set close on exec flag */
328             return fd;
329         }
330         if (!ret) break;
331         if (errno == EINTR) continue;
332         if (errno == EPIPE) break;
333         server_protocol_perror("recvmsg");
334     }
335     /* the server closed the connection; time to die... */
336     SYSDEPS_AbortThread(0);
337 }
338
339
340 /***********************************************************************
341  *           store_cached_fd
342  *
343  * Store the cached fd value for a given handle back into the server.
344  * Returns the new fd, which can be different if there was already an
345  * fd in the cache for that handle.
346  */
347 inline static int store_cached_fd( int fd, obj_handle_t handle )
348 {
349     SERVER_START_REQ( set_handle_info )
350     {
351         req->handle = handle;
352         req->flags  = 0;
353         req->mask   = 0;
354         req->fd     = fd;
355         if (!wine_server_call( req ))
356         {
357             if (reply->cur_fd != fd)
358             {
359                 /* someone was here before us */
360                 close( fd );
361                 fd = reply->cur_fd;
362             }
363         }
364         else
365         {
366             close( fd );
367             fd = -1;
368         }
369     }
370     SERVER_END_REQ;
371     return fd;
372 }
373
374
375 /***********************************************************************
376  *           wine_server_fd_to_handle   (NTDLL.@)
377  *
378  * Allocate a file handle for a Unix fd.
379  */
380 int wine_server_fd_to_handle( int fd, unsigned int access, int inherit, obj_handle_t *handle )
381 {
382     int ret;
383
384     *handle = 0;
385     wine_server_send_fd( fd );
386
387     SERVER_START_REQ( alloc_file_handle )
388     {
389         req->access  = access;
390         req->inherit = inherit;
391         req->fd      = fd;
392         if (!(ret = wine_server_call( req ))) *handle = reply->handle;
393     }
394     SERVER_END_REQ;
395     return ret;
396 }
397
398
399 /***********************************************************************
400  *           wine_server_handle_to_fd   (NTDLL.@)
401  *
402  * Retrieve the Unix fd corresponding to a file handle.
403  */
404 int wine_server_handle_to_fd( obj_handle_t handle, unsigned int access, int *unix_fd,
405                               enum fd_type *type, int *flags )
406 {
407     obj_handle_t fd_handle;
408     int ret, fd = -1;
409
410     *unix_fd = -1;
411     for (;;)
412     {
413         SERVER_START_REQ( get_handle_fd )
414         {
415             req->handle = handle;
416             req->access = access;
417             if (!(ret = wine_server_call( req ))) fd = reply->fd;
418             if (type) *type = reply->type;
419             if (flags) *flags = reply->flags;
420         }
421         SERVER_END_REQ;
422         if (ret) return ret;
423
424         if (fd != -1) break;
425
426         /* it wasn't in the cache, get it from the server */
427         fd = receive_fd( &fd_handle );
428         /* and store it back into the cache */
429         fd = store_cached_fd( fd, fd_handle );
430
431         if (fd_handle == handle) break;
432         /* if we received a different handle this means there was
433          * a race with another thread; we restart everything from
434          * scratch in this case.
435          */
436     }
437
438     if ((fd != -1) && ((fd = dup(fd)) == -1)) return STATUS_TOO_MANY_OPENED_FILES;
439     *unix_fd = fd;
440     return STATUS_SUCCESS;
441 }
442
443
444 /***********************************************************************
445  *           start_server
446  *
447  * Start a new wine server.
448  */
449 static void start_server( const char *oldcwd )
450 {
451     static int started;  /* we only try once */
452     char *path, *p;
453     if (!started)
454     {
455         int status;
456         int pid = fork();
457         if (pid == -1) fatal_perror( "fork" );
458         if (!pid)
459         {
460             /* if server is explicitly specified, use this */
461             if ((p = getenv("WINESERVER")))
462             {
463                 if (p[0] != '/' && oldcwd[0] == '/')  /* make it an absolute path */
464                 {
465                     if (!(path = malloc( strlen(oldcwd) + strlen(p) + 1 )))
466                         fatal_error( "out of memory\n" );
467                     sprintf( path, "%s/%s", oldcwd, p );
468                     p = path;
469                 }
470                 execl( p, p, NULL );
471                 fatal_perror( "could not exec the server '%s'\n"
472                               "    specified in the WINESERVER environment variable", p );
473             }
474
475             /* first try the installation dir */
476             execl( BINDIR "/wineserver", "wineserver", NULL );
477
478             /* now try the dir we were launched from */
479             if (full_argv0)
480             {
481                 if (!(path = malloc( strlen(full_argv0) + 20 )))
482                     fatal_error( "out of memory\n" );
483                 if ((p = strrchr( strcpy( path, full_argv0 ), '/' )))
484                 {
485                     strcpy( p, "/wineserver" );
486                     execl( path, path, NULL );
487                 }
488                 free(path);
489             }
490
491             /* finally try the path */
492             execlp( "wineserver", "wineserver", NULL );
493             fatal_error( "could not exec wineserver\n" );
494         }
495         waitpid( pid, &status, 0 );
496         status = WIFEXITED(status) ? WEXITSTATUS(status) : 1;
497         if (status == 2) return;  /* server lock held by someone else, will retry later */
498         if (status) exit(status);  /* server failed */
499         started = 1;
500     }
501 }
502
503
504 /***********************************************************************
505  *           server_connect_error
506  *
507  * Try to display a meaningful explanation of why we couldn't connect
508  * to the server.
509  */
510 static void server_connect_error( const char *serverdir )
511 {
512     int fd;
513     struct flock fl;
514
515     if ((fd = open( LOCKNAME, O_WRONLY )) == -1)
516         fatal_error( "for some mysterious reason, the wine server never started.\n" );
517
518     fl.l_type   = F_WRLCK;
519     fl.l_whence = SEEK_SET;
520     fl.l_start  = 0;
521     fl.l_len    = 1;
522     if (fcntl( fd, F_GETLK, &fl ) != -1)
523     {
524         if (fl.l_type == F_WRLCK)  /* the file is locked */
525             fatal_error( "a wine server seems to be running, but I cannot connect to it.\n"
526                          "   You probably need to kill that process (it might be pid %d).\n",
527                          (int)fl.l_pid );
528         fatal_error( "for some mysterious reason, the wine server failed to run.\n" );
529     }
530     fatal_error( "the file system of '%s' doesn't support locks,\n"
531           "   and there is a 'socket' file in that directory that prevents wine from starting.\n"
532           "   You should make sure no wine server is running, remove that file and try again.\n",
533                  serverdir );
534 }
535
536
537 /***********************************************************************
538  *           server_connect
539  *
540  * Attempt to connect to an existing server socket.
541  * We need to be in the server directory already.
542  */
543 static int server_connect( const char *oldcwd, const char *serverdir )
544 {
545     struct sockaddr_un addr;
546     struct stat st;
547     int s, slen, retry;
548
549     /* chdir to the server directory */
550     if (chdir( serverdir ) == -1)
551     {
552         if (errno != ENOENT) fatal_perror( "chdir to %s", serverdir );
553         start_server( "." );
554         if (chdir( serverdir ) == -1) fatal_perror( "chdir to %s", serverdir );
555     }
556
557     /* make sure we are at the right place */
558     if (stat( ".", &st ) == -1) fatal_perror( "stat %s", serverdir );
559     if (st.st_uid != getuid()) fatal_error( "'%s' is not owned by you\n", serverdir );
560     if (st.st_mode & 077) fatal_error( "'%s' must not be accessible by other users\n", serverdir );
561
562     for (retry = 0; retry < 6; retry++)
563     {
564         /* if not the first try, wait a bit to leave the previous server time to exit */
565         if (retry)
566         {
567             usleep( 100000 * retry * retry );
568             start_server( oldcwd );
569             if (lstat( SOCKETNAME, &st ) == -1) continue;  /* still no socket, wait a bit more */
570         }
571         else if (lstat( SOCKETNAME, &st ) == -1) /* check for an already existing socket */
572         {
573             if (errno != ENOENT) fatal_perror( "lstat %s/%s", serverdir, SOCKETNAME );
574             start_server( oldcwd );
575             if (lstat( SOCKETNAME, &st ) == -1) continue;  /* still no socket, wait a bit more */
576         }
577
578         /* make sure the socket is sane (ISFIFO needed for Solaris) */
579         if (!S_ISSOCK(st.st_mode) && !S_ISFIFO(st.st_mode))
580             fatal_error( "'%s/%s' is not a socket\n", serverdir, SOCKETNAME );
581         if (st.st_uid != getuid())
582             fatal_error( "'%s/%s' is not owned by you\n", serverdir, SOCKETNAME );
583
584         /* try to connect to it */
585         addr.sun_family = AF_UNIX;
586         strcpy( addr.sun_path, SOCKETNAME );
587         slen = sizeof(addr) - sizeof(addr.sun_path) + strlen(addr.sun_path) + 1;
588 #ifdef HAVE_SOCKADDR_SUN_LEN
589         addr.sun_len = slen;
590 #endif
591         if ((s = socket( AF_UNIX, SOCK_STREAM, 0 )) == -1) fatal_perror( "socket" );
592         if (connect( s, (struct sockaddr *)&addr, slen ) != -1)
593         {
594             fcntl( s, F_SETFD, 1 ); /* set close on exec flag */
595             return s;
596         }
597         close( s );
598     }
599     server_connect_error( serverdir );
600 }
601
602
603 /***********************************************************************
604  *           CLIENT_InitServer
605  *
606  * Start the server and create the initial socket pair.
607  */
608 void CLIENT_InitServer(void)
609 {
610     int size;
611     char *oldcwd;
612     obj_handle_t dummy_handle;
613
614     /* retrieve the current directory */
615     for (size = 512; ; size *= 2)
616     {
617         if (!(oldcwd = malloc( size ))) break;
618         if (getcwd( oldcwd, size )) break;
619         free( oldcwd );
620         if (errno == ERANGE) continue;
621         oldcwd = NULL;
622         break;
623     }
624
625     /* if argv[0] is a relative path, make it absolute */
626     full_argv0 = argv0;
627     if (oldcwd && argv0[0] != '/' && strchr( argv0, '/' ))
628     {
629         char *new_argv0 = malloc( strlen(oldcwd) + strlen(argv0) + 2 );
630         if (new_argv0)
631         {
632             strcpy( new_argv0, oldcwd );
633             strcat( new_argv0, "/" );
634             strcat( new_argv0, argv0 );
635             full_argv0 = new_argv0;
636         }
637     }
638
639     /* connect to the server */
640     fd_socket = server_connect( oldcwd, wine_get_server_dir() );
641
642     /* switch back to the starting directory */
643     if (oldcwd)
644     {
645         chdir( oldcwd );
646         free( oldcwd );
647     }
648
649     /* setup the signal mask */
650     sigemptyset( &block_set );
651     sigaddset( &block_set, SIGALRM );
652     sigaddset( &block_set, SIGIO );
653     sigaddset( &block_set, SIGINT );
654     sigaddset( &block_set, SIGHUP );
655
656     /* receive the first thread request fd on the main socket */
657     NtCurrentTeb()->request_fd = receive_fd( &dummy_handle );
658
659     CLIENT_InitThread();
660 }
661
662
663 /***********************************************************************
664  *           CLIENT_InitThread
665  *
666  * Send an init thread request. Return 0 if OK.
667  */
668 void CLIENT_InitThread(void)
669 {
670     TEB *teb = NtCurrentTeb();
671     int version, ret;
672     int reply_pipe[2];
673
674     /* ignore SIGPIPE so that we get a EPIPE error instead  */
675     signal( SIGPIPE, SIG_IGN );
676     /* automatic child reaping to avoid zombies */
677     signal( SIGCHLD, SIG_IGN );
678
679     /* create the server->client communication pipes */
680     if (pipe( reply_pipe ) == -1) server_protocol_perror( "pipe" );
681     if (pipe( teb->wait_fd ) == -1) server_protocol_perror( "pipe" );
682     wine_server_send_fd( reply_pipe[1] );
683     wine_server_send_fd( teb->wait_fd[1] );
684     teb->reply_fd = reply_pipe[0];
685     close( reply_pipe[1] );
686
687     /* set close on exec flag */
688     fcntl( teb->reply_fd, F_SETFD, 1 );
689     fcntl( teb->wait_fd[0], F_SETFD, 1 );
690     fcntl( teb->wait_fd[1], F_SETFD, 1 );
691
692     SERVER_START_REQ( init_thread )
693     {
694         req->unix_pid    = getpid();
695         req->teb         = teb;
696         req->entry       = teb->entry_point;
697         req->reply_fd    = reply_pipe[1];
698         req->wait_fd     = teb->wait_fd[1];
699         ret = wine_server_call( req );
700         teb->pid = reply->pid;
701         teb->tid = reply->tid;
702         version  = reply->version;
703         if (reply->boot) boot_thread_id = teb->tid;
704         else if (boot_thread_id == teb->tid) boot_thread_id = 0;
705     }
706     SERVER_END_REQ;
707
708     if (ret) server_protocol_error( "init_thread failed with status %x\n", ret );
709     if (version != SERVER_PROTOCOL_VERSION)
710         server_protocol_error( "version mismatch %d/%d.\n"
711                                "Your %s binary was not upgraded correctly,\n"
712                                "or you have an older one somewhere in your PATH.\n"
713                                "Or maybe the wrong wineserver is still running?\n",
714                                version, SERVER_PROTOCOL_VERSION,
715                                (version > SERVER_PROTOCOL_VERSION) ? "wine" : "wineserver" );
716 }
717
718
719 /***********************************************************************
720  *           CLIENT_BootDone
721  *
722  * Signal that we have finished booting, and set debug level.
723  */
724 void CLIENT_BootDone( int debug_level )
725 {
726     SERVER_START_REQ( boot_done )
727     {
728         req->debug_level = debug_level;
729         wine_server_call( req );
730     }
731     SERVER_END_REQ;
732 }
733
734
735 /***********************************************************************
736  *           CLIENT_IsBootThread
737  *
738  * Return TRUE if current thread is the boot thread.
739  */
740 int CLIENT_IsBootThread(void)
741 {
742     return (GetCurrentThreadId() == (DWORD)boot_thread_id);
743 }