Author: adrian.chadd
Date: Sun Apr 5 00:50:52 2009
New Revision: 13913
Modified:
branches/LUSCA_HEAD/libhelper/ipc.c
Log:
Migrate the direct creation of comm sockets out of here and into
libiapp/comm.c .
Modified: branches/LUSCA_HEAD/libhelper/ipc.c
==============================================================================
--- branches/LUSCA_HEAD/libhelper/ipc.c (original)
+++ branches/LUSCA_HEAD/libhelper/ipc.c Sun Apr 5 00:50:52 2009
@@ -173,51 +173,18 @@
COMM_TOS_DEFAULT,
name);
} else if (type == IPC_FIFO) {
- int p2c[2];
- int c2p[2];
- if (pipe(p2c) < 0) {
+ if (! comm_create_fifopair(&prfd, &pwfd, &crfd, &cwfd)) {
debug(54, 0) ("ipcCreate: pipe: %s\n", xstrerror());
- return -1;
- }
- if (pipe(c2p) < 0) {
- debug(54, 0) ("ipcCreate: pipe: %s\n", xstrerror());
- return -1;
- }
- fd_open(prfd = p2c[0], FD_PIPE, "IPC FIFO Parent Read");
- fd_open(cwfd = p2c[1], FD_PIPE, "IPC FIFO Child Write");
- fd_open(crfd = c2p[0], FD_PIPE, "IPC FIFO Child Read");
- fd_open(pwfd = c2p[1], FD_PIPE, "IPC FIFO Parent Write");
- sqinet_init(&fd_table[prfd].local_address);
- sqinet_init(&fd_table[cwfd].local_address);
- sqinet_init(&fd_table[crfd].local_address);
- sqinet_init(&fd_table[pwfd].local_address);
-#if HAVE_SOCKETPAIR && defined(AF_UNIX)
+ }
} else if (type == IPC_UNIX_STREAM) {
- int fds[2];
- int buflen = 32768;
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) {
- debug(54, 0) ("ipcCreate: socketpair: %s\n", xstrerror());
- return -1;
- }
- setsockopt(fds[0], SOL_SOCKET, SO_SNDBUF, (void *) &buflen,
sizeof(buflen));
- setsockopt(fds[0], SOL_SOCKET, SO_RCVBUF, (void *) &buflen,
sizeof(buflen));
- setsockopt(fds[1], SOL_SOCKET, SO_SNDBUF, (void *) &buflen,
sizeof(buflen));
- setsockopt(fds[1], SOL_SOCKET, SO_RCVBUF, (void *) &buflen,
sizeof(buflen));
- fd_open(prfd = pwfd = fds[0], FD_PIPE, "IPC UNIX STREAM Parent");
- fd_open(crfd = cwfd = fds[1], FD_PIPE, "IPC UNIX STREAM Parent");
- sqinet_init(&fd_table[prfd].local_address);
- sqinet_init(&fd_table[crfd].local_address);
+ if (! comm_create_unix_stream_pair(&prfd, &pwfd, &crfd, &cwfd,
32768)) {
+ debug(54, 0) ("ipcCreate: pipe: %s\n", xstrerror());
+ }
} else if (type == IPC_UNIX_DGRAM) {
- int fds[2];
- if (socketpair(AF_UNIX, SOCK_DGRAM, 0, fds) < 0) {
- debug(54, 0) ("ipcCreate: socketpair: %s\n", xstrerror());
- return -1;
- }
- fd_open(prfd = pwfd = fds[0], FD_PIPE, "IPC UNIX DGRAM Parent");
- fd_open(crfd = cwfd = fds[1], FD_PIPE, "IPC UNIX DGRAM Parent");
- sqinet_init(&fd_table[prfd].local_address);
- sqinet_init(&fd_table[crfd].local_address);
-#endif
+ if (! comm_create_unix_dgram_pair(&prfd, &pwfd, &crfd, &cwfd)) {
+ debug(54, 0) ("ipcCreate: dgrampair: %s\n", xstrerror());
+ return -1;
+ }
} else {
assert(IPC_NONE);
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---