summaryrefslogtreecommitdiffstats
path: root/qarsh/qarshd.c
diff options
context:
space:
mode:
Diffstat (limited to 'qarsh/qarshd.c')
-rw-r--r--qarsh/qarshd.c38
1 files changed, 2 insertions, 36 deletions
diff --git a/qarsh/qarshd.c b/qarsh/qarshd.c
index 437645d..9a90782 100644
--- a/qarsh/qarshd.c
+++ b/qarsh/qarshd.c
@@ -83,57 +83,23 @@ run_cmd(const char *cmd, int p_in, int p_out, int p_err)
return pid;
}
-struct qa_packet *
-recv_packet(int fd)
-{
- char *packetbuf;
- int packetsize;
- struct qa_packet *qp = NULL;
-
- packetbuf = malloc(QARSH_MAX_PACKET_SIZE);
- memset(packetbuf, 0, QARSH_MAX_PACKET_SIZE);
-
- packetsize = read(fd, packetbuf, QARSH_MAX_PACKET_SIZE);
- if (packetsize > 0) {
- qp = parse_packets(packetbuf, packetsize);
- }
- free(packetbuf);
- return qp;
-}
-
-int
-send_packet(int fd, struct qa_packet *qp)
-{
- char *packetbuf;
- int packetsize;
-
- packetbuf = malloc(1024);
- memset(packetbuf, 0, 1024);
- packetbuf = qptostr(qp, &packetbuf, &packetsize);
-
- return write(fd, packetbuf, packetsize);
-}
-
void
handle_packets(int infd)
{
fd_set rfds;
- int highfd, nfd;
+ int nfd;
struct timeval timeout;
struct qa_packet *qp = NULL, *rp = NULL;
pid_t child_pid = 0;
int child_status;
- /* set up the select structures */
- highfd = infd+1;
-
for (;;) {
FD_SET(infd, &rfds);
timeout.tv_sec = 5;
timeout.tv_usec = 0;
- nfd = select(highfd, &rfds, NULL, NULL, &timeout);
+ nfd = select(infd+1, &rfds, NULL, NULL, &timeout);
if (nfd < 0) {
syslog(LOG_ERR, "select errno %d, %s\n", errno, strerror(errno));
} else if (nfd > 0) {