This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Fix for libpthreads/manager.c : check for EINTR on read



Hello,

Here is the summary of patch:

          The server thread, pthread_manager() in "manager.c" manages
requests for thread creation and termination. The pthread_create() sends a
request for thread creation to the manager thread, by writing to a pipe.
The manager thread reads the request from the pipe and processes it. During
this read () system call, if there happens to be a signal to the process,
the system call gets interrupted and returns with a return code  -1 and
errno=EINTR( which means "A signal was delivered which awakened the
process"). Thus the read () call for the pipe fails due to the
interruption from the signal.
         And this is not handled correctly in the pthread library. There
need to be a check done for EINTR after system calls return so that we can
call the failed system call again.
         Hence, I have fixed the code in "manager.c" as below, where we are
going in a while loop till EINTR error is not encountered.

PATCH:

=========================================================================

    * linuxthreads/manager.c:   check for EINTR on read

--- linuxthreads/manager.c    Mon Aug 27 14:22:22 2001
+++ /home/guest/manager.c     Mon Aug 27 14:22:07 2001
@@ -150,7 +150,9 @@
     }
     /* Read and execute request */
     if (n == 1 && (ufd.revents & POLLIN)) {
+      do {
       n = __libc_read(reqfd, (char *)&request, sizeof(request));
+      } while(n == -1 && errno == EINTR);
       ASSERT(n == sizeof(request));
       switch(request.req_kind) {
       case REQ_CREATE:


=========================================================================



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]