return(fd[1]);
}
-int sendfd(int sock, int fd, char *data, size_t datalen)
+int sendfd2(int sock, int fd, char *data, size_t datalen, int flags)
{
struct msghdr msg;
struct cmsghdr *cmsg;
*((int *)CMSG_DATA(cmsg)) = fd;
msg.msg_controllen = cmsg->cmsg_len;
- return(sendmsg(sock, &msg, MSG_NOSIGNAL | MSG_DONTWAIT));
+ return(sendmsg(sock, &msg, flags));
+}
+
+int sendfd(int sock, int fd, char *data, size_t datalen)
+{
+ return(sendfd2(sock, fd, data, datalen, MSG_NOSIGNAL | MSG_DONTWAIT));
}
int recvfd(int sock, char **data, size_t *datalen)
#include "req.h"
int stdmkchild(char **argv, void (*chinit)(void *), void *idata);
+int sendfd2(int sock, int fd, char *data, size_t datalen, int flags);
int sendfd(int sock, int fd, char *data, size_t datalen);
int recvfd(int sock, char **data, size_t *datalen);
pid_t stdforkserve(char **argv, struct hthead *req, int fd, void (*chinit)(void *), void *idata);
return(0);
}
-int sendreq(int sock, struct hthead *req, int fd)
+int sendreq2(int sock, struct hthead *req, int fd, int flags)
{
int ret, i;
struct charbuf buf;
bufcatstr2(buf, req->headers[i][1]);
}
bufcatstr2(buf, "");
- ret = sendfd(sock, fd, buf.b, buf.d);
+ ret = sendfd2(sock, fd, buf.b, buf.d, flags);
buffree(buf);
if(ret < 0)
return(-1);
return(0);
}
+int sendreq(int sock, struct hthead *req, int fd)
+{
+ return(sendreq2(sock, req, fd, MSG_NOSIGNAL | MSG_DONTWAIT));
+}
+
int recvreq(int sock, struct hthead **reqp)
{
int fd;
void headpreheader(struct hthead *head, const char *name, const char *val);
void headappheader(struct hthead *head, const char *name, const char *val);
void headrmheader(struct hthead *head, const char *name);
+int sendreq2(int sock, struct hthead *req, int fd, int flags);
int sendreq(int sock, struct hthead *req, int fd);
int recvreq(int sock, struct hthead **reqp);
void replrest(struct hthead *head, char *rest);