summaryrefslogtreecommitdiff
path: root/tcp.c
diff options
context:
space:
mode:
authorFabian Mauchle <fabian.mauchle@switch.ch>2017-03-02 10:44:16 +0100
committerFabian Mauchle <fabian.mauchle@switch.ch>2017-03-16 11:16:58 +0100
commit6be11441945bf33f807568d8566dffc7fef9174f (patch)
tree42e1656d74a9e593e54a24e68a42c50145a6102d /tcp.c
parent750a3811adb90c9727b11af1fb385862da8a6f60 (diff)
replace server states with enum
Conflicts: radsecproxy.c radsecproxy.h
Diffstat (limited to 'tcp.c')
-rw-r--r--tcp.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/tcp.c b/tcp.c
index 77a6044..c213594 100644
--- a/tcp.c
+++ b/tcp.c
@@ -102,8 +102,8 @@ int tcpconnect(struct server *server, struct timeval *when, int timeout, char *t
pthread_mutex_unlock(&server->lock);
return 0;
}
- if (server->connectionok) {
- server->connectionok = 0;
+ if (server->state == SERVER_STATE_CONNECTED) {
+ server->state = SERVER_STATE_RECONNECTING;
sleep(2);
} else if (elapsed < 1)
sleep(2);
@@ -121,7 +121,7 @@ int tcpconnect(struct server *server, struct timeval *when, int timeout, char *t
if ((server->sock = connecttcphostlist(server->conf->hostports, srcres)) >= 0)
break;
}
- server->connectionok = 1;
+ server->state = SERVER_STATE_CONNECTED;
gettimeofday(&server->lastconnecttry, NULL);
pthread_mutex_unlock(&server->lock);
return 1;
@@ -202,7 +202,7 @@ int clientradputtcp(struct server *server, unsigned char *rad) {
size_t len;
struct clsrvconf *conf = server->conf;
- if (!server->connectionok)
+ if (!server->state == SERVER_STATE_CONNECTED)
return 0;
len = RADLEN(rad);
if ((cnt = write(server->sock, rad, len)) <= 0) {