socsvn commit: r253699 - soc2013/dpl/head/contrib/bzip2
dpl at FreeBSD.org
dpl at FreeBSD.org
Sat Jun 29 21:38:05 UTC 2013
Author: dpl
Date: Sat Jun 29 21:38:04 2013
New Revision: 253699
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253699
Log:
Minor code changes, still not working.
Modified:
soc2013/dpl/head/contrib/bzip2/bzip2.c
Modified: soc2013/dpl/head/contrib/bzip2/bzip2.c
==============================================================================
--- soc2013/dpl/head/contrib/bzip2/bzip2.c Sat Jun 29 20:17:14 2013 (r253698)
+++ soc2013/dpl/head/contrib/bzip2/bzip2.c Sat Jun 29 21:38:04 2013 (r253699)
@@ -231,8 +231,6 @@
int
sendfd(int s, int fd)
{
- printf("sendfd on socket:%d fd:%d\n",s,fd);
-
struct msghdr msg;
struct cmsghdr cmsg;
char buf = { "!" };
@@ -248,14 +246,11 @@
msg.msg_control = &cmsg;
msg.msg_controllen = CMSG_LEN(sizeof(int));
- printf("About to set CMSG\n");
cmsg.cmsg_len = msg.msg_controllen;
cmsg.cmsg_level = SOL_SOCKET;
cmsg.cmsg_type = SCM_RIGHTS;
- printf("About to set CMSG_DATA as fd\n");
*(int *)CMSG_DATA(&cmsg) = fd;
- printf("CMSG_DATA = fd\n");
- if(sendmsg(s, &msg, 0) < 0)
+ if(sendmsg(s, &msg, 0) <= 0)
return -1;
return 0;
}
@@ -263,7 +258,6 @@
int
recvfd(int s)
{
-
int fd;
struct msghdr msg;
struct cmsghdr cmsg;
@@ -287,7 +281,7 @@
if(recvmsg(s, &msg, 0) < 0)
return -1;
fd = *(int *)CMSG_DATA(&cmsg);
- printf("recvfd() fd recieved: %d", fd);
+ printf("recvfd() fd recieved: %d\n", *((int *)CMSG_DATA(&cmsg)));
return 0;
}
#endif
@@ -1403,13 +1397,13 @@
exit(exitValue);
case ( 0 ):
- if ((close(sv[0])) < 0){
+ /*if ((close(sv[0])) < 0){
fprintf ( stderr, "%s: Couldn't close socket: %s.\n",
progName, strerror(errno) );
setExit(1);
exit(exitValue);
- }
- printf("About to recv infd\n");
+ }*/
+ printf("About to recv infd\n");
sleep(1);
if ((infd = recvfd(sv[1])) < 0){
fprintf ( stderr, "%s: Couldn't get infd: %s.\n",
@@ -1459,21 +1453,24 @@
default:
printf("Parent: infd:%d, outfd:%d\n", infd, outfd);
- if ((close(sv[1])) < 0){
+ /*if ((close(sv[1])) < 0){
fprintf ( stderr, "%s: Couldn't close fd: %s.\n",
progName, strerror(errno) );
+ wait(NULL);
setExit(1);
exit(exitValue);
- }
+ }*/
if (sendfd(sv[0], infd) < 0){
fprintf ( stderr, "%s: Couldn't send infd: %s.\n",
progName, strerror(errno) );
+ wait(NULL);
setExit(1);
exit(exitValue);
}
if (sendfd(sv[0], outfd) < 0){
fprintf ( stderr, "%s: Couldn't send outfd: %s.\n",
progName, strerror(errno) );
+ wait(NULL);
setExit(1);
exit(exitValue);
}
@@ -2139,6 +2136,7 @@
setExit(1);
exit(exitValue);
}
+ printf("socketpair() ended fine: sv[0]:%d sv[1]:%d\n", sv[0], sv[1]);
# endif
More information about the svn-soc-all
mailing list