summaryrefslogtreecommitdiff
path: root/pflocal
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2002-04-24 16:20:53 +0000
committerMarcus Brinkmann <marcus@gnu.org>2002-04-24 16:20:53 +0000
commit5300252b6a150f8ad36dbca57d4998a4b1bc0f22 (patch)
tree553c7dba1cd4fcea5b76853764cce4bed797b19d /pflocal
parent1cb3febfc01ceda874aebcd3aaac6aff88b30684 (diff)
2002-04-24 Ognyan Kulev <ogi@fmi.uni-sofia.bg>
* sock.c (sock_shutdown): When both SHUTDOWN_READ and SHUTDOWN_WRITE are set in FLAGS unlock sock->lock after all processing of `sock' is finished. (sock_create): Replace bzero with memset.
Diffstat (limited to 'pflocal')
-rw-r--r--pflocal/ChangeLog7
-rw-r--r--pflocal/sock.c43
2 files changed, 24 insertions, 26 deletions
diff --git a/pflocal/ChangeLog b/pflocal/ChangeLog
index ba735ed13..cb5a8f724 100644
--- a/pflocal/ChangeLog
+++ b/pflocal/ChangeLog
@@ -1,3 +1,10 @@
+2002-04-24 Ognyan Kulev <ogi@fmi.uni-sofia.bg>
+
+ * sock.c (sock_shutdown): When both SHUTDOWN_READ and
+ SHUTDOWN_WRITE are set in FLAGS unlock sock->lock after all
+ processing of `sock' is finished.
+ (sock_create): Replace bzero with memset.
+
2001-12-22 Roland McGrath <roland@frob.com>
* connq.c (connq_compress): #if 0 out unused function.
diff --git a/pflocal/sock.c b/pflocal/sock.c
index c947faf32..0b11c54a9 100644
--- a/pflocal/sock.c
+++ b/pflocal/sock.c
@@ -1,6 +1,6 @@
/* Sock functions
- Copyright (C) 1995,96,2000,01 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,2000,01,02 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.org>
This program is free software; you can redistribute it and/or
@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include <string.h> /* For bzero() */
+#include <string.h> /* For memset() */
#include <cthreads.h>
@@ -122,7 +122,7 @@ sock_create (struct pipe_class *pipe_class, mode_t mode, struct sock **sock)
new->connect_queue = NULL;
new->pipe_class = pipe_class;
new->addr = NULL;
- bzero (&new->change_time, sizeof (new->change_time));
+ memset (&new->change_time, 0, sizeof (new->change_time));
mutex_init (&new->lock);
*sock = new;
@@ -449,6 +449,8 @@ void
sock_shutdown (struct sock *sock, unsigned flags)
{
unsigned old_flags;
+ struct pipe *read_pipe = NULL;
+ struct pipe *write_pipe = NULL;
mutex_lock (&sock->lock);
@@ -458,34 +460,23 @@ sock_shutdown (struct sock *sock, unsigned flags)
if (flags & SOCK_SHUTDOWN_READ && !(old_flags & SOCK_SHUTDOWN_READ))
/* Shutdown the read half. */
{
- struct pipe *pipe = sock->read_pipe;
- if (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);
+ read_pipe = sock->read_pipe;
+ sock->read_pipe = NULL;
}
-
if (flags & SOCK_SHUTDOWN_WRITE && !(old_flags & SOCK_SHUTDOWN_WRITE))
/* Shutdown the write half. */
{
- struct pipe *pipe = sock->write_pipe;
- if (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);
+ write_pipe = sock->write_pipe;
+ sock->write_pipe = NULL;
}
- else
- mutex_unlock (&sock->lock);
+
+ /* Unlock SOCK here, as we may subsequently wake up other threads. */
+ mutex_unlock (&sock->lock);
+
+ if (read_pipe)
+ pipe_remove_reader (read_pipe);
+ if (write_pipe)
+ pipe_remove_writer (write_pipe);
}
/* ---------------------------------------------------------------- */