struct iovec io;
io.iov_base = &length;
- io.iov_len = sizeof(size_t);
+ io.iov_len = sizeof(length);
msg.msg_iov = &io;
msg.msg_iovlen = 1;
int rc = recvmsg(l_ProcessControlFD, &msg, 0);
- if (rc < 0 && (errno == EINTR || errno == EAGAIN))
- continue;
-
- if (rc < 0) {
- BOOST_THROW_EXCEPTION(posix_error()
- << boost::errinfo_api_function("recvmsg")
- << boost::errinfo_errno(errno));
- }
+ if (rc <= 0) {
+ if (rc < 0 && (errno == EINTR || errno == EAGAIN))
+ continue;
- if (length > 1024 * 1024 * 1024) {
- BOOST_THROW_EXCEPTION(std::runtime_error("invalid message length"));
+ break;
}
char *mbuf = new char[length];
while (count < length) {
rc = recv(l_ProcessControlFD, mbuf + count, length - count, 0);
- if (rc < 0) {
- if (errno == EINTR || errno == EAGAIN)
- continue;
+ if (rc <= 0) {
+ if (rc < 0 && (errno == EINTR || errno == EAGAIN))
+ continue;
delete [] mbuf;
- BOOST_THROW_EXCEPTION(posix_error()
- << boost::errinfo_api_function("recv")
- << boost::errinfo_errno(errno));
+ _exit(0);
}
count += rc;
struct iovec io;
io.iov_base = &length;
- io.iov_len = sizeof(size_t);
+ io.iov_len = sizeof(length);
msg.msg_iov = &io;
msg.msg_iovlen = 1;
msg.msg_controllen = cmsg->cmsg_len;
+send_message:
while (sendmsg(l_ProcessControlFD, &msg, 0) < 0)
StartSpawnProcessHelper();
- if (send(l_ProcessControlFD, jrequest.CStr(), jrequest.GetLength(), 0) < 0) {
- BOOST_THROW_EXCEPTION(posix_error()
- << boost::errinfo_api_function("send")
- << boost::errinfo_errno(errno));
- }
+ if (send(l_ProcessControlFD, jrequest.CStr(), jrequest.GetLength(), 0) < 0)
+ goto send_message;
char buf[4096];
boost::mutex::scoped_lock lock(l_ProcessControlMutex);
- while (send(l_ProcessControlFD, &length, sizeof(size_t), 0) < 0)
+send_message:
+ while (send(l_ProcessControlFD, &length, sizeof(length), 0) < 0)
StartSpawnProcessHelper();
- if (send(l_ProcessControlFD, jrequest.CStr(), jrequest.GetLength(), 0) < 0) {
- BOOST_THROW_EXCEPTION(posix_error()
- << boost::errinfo_api_function("send")
- << boost::errinfo_errno(errno));
- }
+ if (send(l_ProcessControlFD, jrequest.CStr(), jrequest.GetLength(), 0) < 0)
+ goto send_message;
char buf[4096];
boost::mutex::scoped_lock lock(l_ProcessControlMutex);
- while (send(l_ProcessControlFD, &length, sizeof(size_t), 0) < 0)
+send_message:
+ while (send(l_ProcessControlFD, &length, sizeof(length), 0) < 0)
StartSpawnProcessHelper();
- if (send(l_ProcessControlFD, jrequest.CStr(), jrequest.GetLength(), 0) < 0) {
- BOOST_THROW_EXCEPTION(posix_error()
- << boost::errinfo_api_function("send")
- << boost::errinfo_errno(errno));
- }
+ if (send(l_ProcessControlFD, jrequest.CStr(), jrequest.GetLength(), 0) < 0)
+ goto send_message;
char buf[4096];