db_sqlite: rename database scheme files, to allow automatic updates
[sip-router] / pass_fd.c
index 7a2b30c..26e64f5 100644 (file)
--- a/pass_fd.c
+++ b/pass_fd.c
   *  2008-04-30  added MSG_WAITALL emulation for cygwin (andrei)
   */
 
+/*!
+ * \file
+ * \brief SIP-router core :: 
+ * \ingroup core
+ * Module: \ref core
+ */
+
 #ifdef USE_TCP
 
 #include "pass_fd.h"
@@ -160,6 +167,7 @@ int send_fd(int unix_socket, void* data, int data_len, int fd)
        struct iovec iov[1];
        int ret;
 #ifdef HAVE_MSGHDR_MSG_CONTROL
+       int* pi;
        struct cmsghdr* cmsg;
        /* make sure msg_control will point to properly aligned data */
        union {
@@ -176,7 +184,8 @@ int send_fd(int unix_socket, void* data, int data_len, int fd)
        cmsg->cmsg_level = SOL_SOCKET;
        cmsg->cmsg_type = SCM_RIGHTS;
        cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
-       *(int*)CMSG_DATA(cmsg)=fd;
+       pi=(int*)CMSG_DATA(cmsg);
+       *pi=fd;
        msg.msg_flags=0;
 #else
        msg.msg_accrights=(caddr_t) &fd;
@@ -196,8 +205,8 @@ again:
        if (ret<0){
                if (errno==EINTR) goto again;
                if ((errno!=EAGAIN) && (errno!=EWOULDBLOCK))
-                       LOG(L_CRIT, "ERROR: send_fd: sendmsg failed on %d: %s\n",
-                                       unix_socket, strerror(errno));
+                       LOG(L_CRIT, "ERROR: send_fd: sendmsg failed sending %d on %d:"
+                                               " %s (%d)\n", fd, unix_socket, strerror(errno), errno);
        }
        
        return ret;
@@ -225,6 +234,7 @@ int receive_fd(int unix_socket, void* data, int data_len, int* fd, int flags)
        int f;
 #endif /*NO_MSG_WAITALL */
 #ifdef HAVE_MSGHDR_MSG_CONTROL
+       int* pi;
        struct cmsghdr* cmsg;
        union{
                struct cmsghdr cm;
@@ -308,7 +318,8 @@ poll_again:
                        ret=-1;
                        goto error;
                }
-               *fd=*((int*) CMSG_DATA(cmsg));
+               pi=(int*) CMSG_DATA(cmsg);
+               *fd=*pi;
        }else{
                /*
                LOG(L_ERR, "ERROR: receive_fd: no descriptor passed, cmsg=%p,"