/[hurd]/hurd/pflocal/sock.c
ViewVC logotype

Diff of /hurd/pflocal/sock.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by roland, Sun Apr 1 01:40:12 2001 UTC revision 1.28 by marcus, Wed Apr 24 16:20:53 2002 UTC
# Line 1  Line 1 
1  /* Sock functions  /* Sock functions
2    
3     Copyright (C) 1995,96,2000,01 Free Software Foundation, Inc.     Copyright (C) 1995,96,2000,01,02 Free Software Foundation, Inc.
4     Written by Miles Bader <miles@gnu.org>     Written by Miles Bader <miles@gnu.org>
5    
6     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
# Line 17  Line 17 
17     along with this program; if not, write to the Free Software     along with this program; if not, write to the Free Software
18     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19    
20  #include <string.h>             /* For bzero() */  #include <string.h>             /* For memset() */
21    
22  #include <cthreads.h>  #include <cthreads.h>
23    
# Line 122  sock_create (struct pipe_class *pipe_cla Line 122  sock_create (struct pipe_class *pipe_cla
122    new->connect_queue = NULL;    new->connect_queue = NULL;
123    new->pipe_class = pipe_class;    new->pipe_class = pipe_class;
124    new->addr = NULL;    new->addr = NULL;
125    bzero (&new->change_time, sizeof (new->change_time));    memset (&new->change_time, 0, sizeof (new->change_time));
126    mutex_init (&new->lock);    mutex_init (&new->lock);
127    
128    *sock = new;    *sock = new;
# Line 449  void Line 449  void
449  sock_shutdown (struct sock *sock, unsigned flags)  sock_shutdown (struct sock *sock, unsigned flags)
450  {  {
451    unsigned old_flags;    unsigned old_flags;
452      struct pipe *read_pipe = NULL;
453      struct pipe *write_pipe = NULL;
454    
455    mutex_lock (&sock->lock);    mutex_lock (&sock->lock);
456    
# Line 458  sock_shutdown (struct sock *sock, unsign Line 460  sock_shutdown (struct sock *sock, unsign
460    if (flags & SOCK_SHUTDOWN_READ && !(old_flags & SOCK_SHUTDOWN_READ))    if (flags & SOCK_SHUTDOWN_READ && !(old_flags & SOCK_SHUTDOWN_READ))
461      /* Shutdown the read half.  */      /* Shutdown the read half.  */
462      {      {
463        struct pipe *pipe = sock->read_pipe;        read_pipe = sock->read_pipe;
464        if (pipe != NULL)        sock->read_pipe = NULL;
         {  
           sock->read_pipe = NULL;  
           /* Unlock SOCK here, as we may subsequently wake up other threads. */  
           mutex_unlock (&sock->lock);  
           pipe_remove_reader (pipe);  
         }  
       else  
         mutex_unlock (&sock->lock);  
465      }      }
   
466    if (flags & SOCK_SHUTDOWN_WRITE && !(old_flags & SOCK_SHUTDOWN_WRITE))    if (flags & SOCK_SHUTDOWN_WRITE && !(old_flags & SOCK_SHUTDOWN_WRITE))
467      /* Shutdown the write half.  */      /* Shutdown the write half.  */
468      {      {
469        struct pipe *pipe = sock->write_pipe;        write_pipe = sock->write_pipe;
470        if (pipe != NULL)        sock->write_pipe = NULL;
         {  
           sock->write_pipe = NULL;  
           /* Unlock SOCK here, as we may subsequently wake up other threads. */  
           mutex_unlock (&sock->lock);  
           pipe_remove_writer (pipe);  
         }  
       else  
         mutex_unlock (&sock->lock);  
471      }      }
472    else  
473      mutex_unlock (&sock->lock);    /* Unlock SOCK here, as we may subsequently wake up other threads. */
474      mutex_unlock (&sock->lock);
475      
476      if (read_pipe)
477        pipe_remove_reader (read_pipe);
478      if (write_pipe)
479        pipe_remove_writer (write_pipe);
480  }  }
481    
482  /* ---------------------------------------------------------------- */  /* ---------------------------------------------------------------- */

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26