--- libaitio/src/sock.c 2013/12/15 22:57:20 1.12 +++ libaitio/src/sock.c 2014/04/29 01:26:21 1.14.4.1 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: sock.c,v 1.12 2013/12/15 22:57:20 misho Exp $ +* $Id: sock.c,v 1.14.4.1 2014/04/29 01:26:21 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 +Copyright 2004 - 2014 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -211,16 +211,19 @@ io_rxNet(sched_task_t *task) else { rlen = recvfrom(TASK_FD(task), AIT_GET_BUF(&cli->cli_buf[0]), AIT_LEN(&cli->cli_buf[0]), 0, &sa.sa, &salen); - if (e_addrcmp(&cli->cli_addr, &sa, 42)) - goto end; + if (e_addrcmp(&cli->cli_addr, &sa, 42)) { + schedReadSelf(task); + taskExit(task, NULL); + } } if (rlen < 1) schedEvent(TASK_ROOT(task), io_closeClient, cli, 0, NULL, 0); - else + else { schedEvent(TASK_ROOT(task), io_txPty, cli, cli->cli_pty, AIT_GET_BUF(&cli->cli_buf[0]), rlen); -end: - schedReadSelf(task); + schedReadSelf(task); + } + taskExit(task, NULL); } @@ -235,18 +238,19 @@ io_rxPty(sched_task_t *task) rlen = read(TASK_FD(task), AIT_GET_BUF(&cli->cli_buf[1]), AIT_LEN(&cli->cli_buf[1])); if (rlen < 1) schedEvent(TASK_ROOT(task), io_closeClient, cli, 0, NULL, 0); - else + else { schedEvent(TASK_ROOT(task), io_txNet, cli, cli->cli_fd, AIT_GET_BUF(&cli->cli_buf[1]), rlen); + schedReadSelf(task); + } - schedReadSelf(task); taskExit(task, NULL); } static void * io_bridgeClient(sched_task_t *task) { - int c, rlen; + int c, rlen, pty; pid_t pid; sockaddr_t sa; socklen_t salen = sizeof sa.ss; @@ -290,12 +294,14 @@ io_bridgeClient(sched_task_t *task) AIT_SET_BUFSIZ(&cli->cli_buf[0], 0, AIT_LEN(&s->sock_buf)); AIT_SET_BUFSIZ(&cli->cli_buf[1], 0, AIT_LEN(&s->sock_buf)); - switch ((pid = ioForkPTY(&cli->cli_pty, cli->cli_name, sizeof cli->cli_name, + switch ((pid = ioForkPTY(&pty, cli->cli_name, sizeof cli->cli_name, NULL, NULL, NULL))) { case -1: ELIBERR(io); break; case 0: + cli->cli_pty = pty; + array_Args(cli->cli_cmdline, 0, " \t", &args); argv = array_To(args); array_Destroy(&args); @@ -307,6 +313,7 @@ io_bridgeClient(sched_task_t *task) _exit(rlen); break; default: + cli->cli_pty = pty; cli->cli_pid = pid; schedRead(TASK_ROOT(task), io_rxPty, cli, cli->cli_pty,