projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
get the spotted and spotter the right way around
[spider.git]
/
src
/
client.c
diff --git
a/src/client.c
b/src/client.c
index 049d64f6a2fd9d833365b8d6340f3d2ac54cbace..5ff3401097726493f6a0c7b0533a0698139e336e 100644
(file)
--- a/
src/client.c
+++ b/
src/client.c
@@
-375,12
+375,12
@@
int fcb_handler(sel_t *sp, int in, int out, int err)
default:
dbg(DBUF,"got errno %d in input", errno);
ending++;
default:
dbg(DBUF,"got errno %d in input", errno);
ending++;
- return
0
;
+ return
1
;
}
} else if (r == 0) {
dbg(DBUF, "ending normally");
ending++;
}
} else if (r == 0) {
dbg(DBUF, "ending normally");
ending++;
- return
0
;
+ return
1
;
}
dbgdump(DBUF, "in ->", buf, r);
}
dbgdump(DBUF, "in ->", buf, r);
@@
-723,13
+723,9
@@
void process_node()
void term_timeout(int i)
{
/* none of this is going to be reused so don't bother cleaning up properly */
void term_timeout(int i)
{
/* none of this is going to be reused so don't bother cleaning up properly */
- if (in && in->t_set)
- tcsetattr(0, TCSANOW, &in->t);
- if (node) {
- shutdown(node->cnum, 3);
- close(node->cnum);
- }
- exit(i);
+ if (isatty(0))
+ tcflush(0, TCIOFLUSH);
+ kill(getpid(), 9); /* commit suicide */
}
void terminate(int i)
}
void terminate(int i)
@@
-737,16
+733,22
@@
void terminate(int i)
signal(SIGALRM, term_timeout);
alarm(10);
signal(SIGALRM, term_timeout);
alarm(10);
- while ((in && !is_chain_empty(in->outq)) ||
- (node && !is_chain_empty(node->outq))) {
+ if (node && node->sp->sort) {
+ sel_close(node->sp);
+ }
+ while (in && in->sp->sort && !is_chain_empty(in->outq)) {
sel_run();
}
sel_run();
}
+ sel_run();
+ sel_run();
+ sel_run();
+ sel_run();
+ sel_run();
+ sel_run();
+ sel_run();
+ sel_run();
if (in && in->t_set)
tcsetattr(0, TCSADRAIN, &in->t);
if (in && in->t_set)
tcsetattr(0, TCSADRAIN, &in->t);
- if (node) {
- shutdown(node->cnum, 3);
- close(node->cnum);
- }
exit(i);
}
exit(i);
}
@@
-754,10
+756,7
@@
void login_timeout(int i)
{
write(0, "Timed Out", 10);
write(0, &nl, 1);
{
write(0, "Timed Out", 10);
write(0, &nl, 1);
- sel_run(); /* force a coordination */
- if (in && in->t_set)
- tcsetattr(0, TCSANOW, &in->t);
- exit(i);
+ terminate(0);
}
/*
}
/*
@@
-825,6
+824,7
@@
void connect_to_node()
struct hostent *hp, *gethostbyname();
struct sockaddr_in server;
int nodef;
struct hostent *hp, *gethostbyname();
struct sockaddr_in server;
int nodef;
+ int one = 1;
sel_t *sp;
struct linger lg;
sel_t *sp;
struct linger lg;
@@
-848,6
+848,9
@@
void connect_to_node()
if (setsockopt(nodef, SOL_SOCKET, SO_LINGER, &lg, sizeof lg) < 0) {
die("Error on SO_LINGER to %s port %d (%d)", node_addr, node_port, errno);
}
if (setsockopt(nodef, SOL_SOCKET, SO_LINGER, &lg, sizeof lg) < 0) {
die("Error on SO_LINGER to %s port %d (%d)", node_addr, node_port, errno);
}
+ if (setsockopt(nodef, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one) < 0) {
+ die("Error on SO_KEEPALIVE to %s port %d (%d)", node_addr, node_port, errno);
+ }
node = fcb_new(nodef, MSG);
node->sp = sel_open(nodef, node, "Msg System", fcb_handler, MSG, SEL_INPUT);
node = fcb_new(nodef, MSG);
node->sp = sel_open(nodef, node, "Msg System", fcb_handler, MSG, SEL_INPUT);
@@
-915,8
+918,7
@@
main(int argc, char *argv[])
/* connect up stdin */
in = fcb_new(0, TEXT);
in->sp = sel_open(0, in, "STDIN", fcb_handler, TEXT, SEL_INPUT);
/* connect up stdin */
in = fcb_new(0, TEXT);
in->sp = sel_open(0, in, "STDIN", fcb_handler, TEXT, SEL_INPUT);
- if (tcgetattr(0, &in->t) < 0) {
-/* echo = 0; */
+ if (!isatty(0) || tcgetattr(0, &in->t) < 0) {
in->echo = echo;
in->t_set = 0;
} else {
in->echo = echo;
in->t_set = 0;
} else {