aboutsummaryrefslogtreecommitdiffstats
path: root/src/symsocket.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/symsocket.c')
-rw-r--r--src/symsocket.c104
1 files changed, 50 insertions, 54 deletions
diff --git a/src/symsocket.c b/src/symsocket.c
index 461ed12..15b58c5 100644
--- a/src/symsocket.c
+++ b/src/symsocket.c
@@ -1,4 +1,4 @@
-/*
+/*
* symsocket.c:
*
* Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
@@ -9,8 +9,11 @@
static char rcsid[] =
"$Id$";
-/*
+/*
* $Log$
+ * Revision 1.11 2008/03/07 12:37:04 james
+ * *** empty log message ***
+ *
* Revision 1.10 2008/03/03 18:16:16 james
* *** empty log message ***
*
@@ -92,11 +95,10 @@ socket_free (Socket * s)
slide_free (s->read_buf);
if (s->write_buf)
slide_free (s->write_buf);
- if (s->path_to_unlink)
- {
- unlink (s->path_to_unlink);
- free (s->path_to_unlink);
- }
+ if (s->path_to_unlink) {
+ unlink (s->path_to_unlink);
+ free (s->path_to_unlink);
+ }
close (s->fd);
free (s);
}
@@ -141,20 +143,18 @@ socket_listen (char *path)
sun->sun_family = AF_UNIX;
strcpy (sun->sun_path, path);
- if (bind (fd, (struct sockaddr *) sun, SUN_LEN (sun)) < 0)
- {
- free (sun);
- close (fd);
- return NULL;
- }
+ if (bind (fd, (struct sockaddr *) sun, SUN_LEN (sun)) < 0) {
+ free (sun);
+ close (fd);
+ return NULL;
+ }
free (sun);
- if (listen (fd, 5) < 0)
- {
- close (fd);
- return NULL;
- }
+ if (listen (fd, 5) < 0) {
+ close (fd);
+ return NULL;
+ }
set_nonblocking (fd);
@@ -200,7 +200,7 @@ socket_accept (Socket * l)
}
-/*Blocking for now*/
+/* Blocking for now */
Socket *
socket_connect (char *path)
{
@@ -222,12 +222,11 @@ socket_connect (char *path)
sun->sun_family = AF_UNIX;
strcpy (sun->sun_path, path);
- if (connect (fd, (struct sockaddr *) sun, SUN_LEN (sun)))
- {
- free (sun);
- close (fd);
- return NULL;
- }
+ if (connect (fd, (struct sockaddr *) sun, SUN_LEN (sun))) {
+ free (sun);
+ close (fd);
+ return NULL;
+ }
free (sun);
@@ -263,12 +262,11 @@ socket_pre_select (Socket * s, fd_set * rfds, fd_set * wfds)
char buf[1024];
int n;
- /*Server socket */
- if (SOCKET_IS_LISTENER (s))
- {
- FD_SET (s->fd, rfds);
- return;
- }
+ /* Server socket */
+ if (SOCKET_IS_LISTENER (s)) {
+ FD_SET (s->fd, rfds);
+ return;
+ }
if (!SLIDE_EMPTY (s->write_buf))
FD_SET (s->fd, wfds);
@@ -286,29 +284,27 @@ socket_post_select (Socket * s, fd_set * rfds, fd_set * wfds)
int error = 0;
- if ((!SLIDE_EMPTY (s->write_buf)) && FD_ISSET (s->fd, wfds))
- {
- n =
- (SLIDE_BYTES (s->write_buf) >
- MAX_TXN) ? MAX_TXN : SLIDE_BYTES (s->write_buf);
- n = wrap_send (s->fd, SLIDE_RPTR (s->write_buf), n);
- if (n > 0)
- slide_consume (s->write_buf, n);
- if (n < 0)
- error = -1;
- }
-
- if (!SLIDE_FULL (s->read_buf) && FD_ISSET (s->fd, rfds))
- {
- n =
- (SLIDE_SPACE (s->read_buf) >
- MAX_TXN) ? MAX_TXN : SLIDE_SPACE (s->read_buf);
- n = wrap_recv (s->fd, SLIDE_WPTR (s->read_buf), n);
- if (n > 0)
- slide_added (s->read_buf, n);
- if (n < 0)
- error = -1;
- }
+ if ((!SLIDE_EMPTY (s->write_buf)) && FD_ISSET (s->fd, wfds)) {
+ n =
+ (SLIDE_BYTES (s->write_buf) >
+ MAX_TXN) ? MAX_TXN : SLIDE_BYTES (s->write_buf);
+ n = wrap_send (s->fd, SLIDE_RPTR (s->write_buf), n);
+ if (n > 0)
+ slide_consume (s->write_buf, n);
+ if (n < 0)
+ error = -1;
+ }
+
+ if (!SLIDE_FULL (s->read_buf) && FD_ISSET (s->fd, rfds)) {
+ n =
+ (SLIDE_SPACE (s->read_buf) >
+ MAX_TXN) ? MAX_TXN : SLIDE_SPACE (s->read_buf);
+ n = wrap_recv (s->fd, SLIDE_WPTR (s->read_buf), n);
+ if (n > 0)
+ slide_added (s->read_buf, n);
+ if (n < 0)
+ error = -1;
+ }
s->msg = ipc_check_for_message_in_slide (s->read_buf);