summaryrefslogtreecommitdiffstats
path: root/PICA_client.c
diff options
context:
space:
mode:
authorme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2012-09-16 20:47:33 +0000
committerme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2012-09-16 20:47:33 +0000
commite4235cc56031fda02663b9e638ed29613a47cfdd (patch)
tree91ac618b0291074e22419ebad026857fe2409d21 /PICA_client.c
parent15cdb926992e8b2bf29751a889512edb793c9951 (diff)
downloadpica-pica-e4235cc56031fda02663b9e638ed29613a47cfdd.tar.gz
pica-pica-e4235cc56031fda02663b9e638ed29613a47cfdd.zip
close channel by client if it is not activated within PICA_CHAN_ACTIVATE_TIMEOUT seconds
git-svn-id: svn://localhost/project_picapica/trunk@204 fb96df88-216d-11de-830c-f3023f12d8ac
Diffstat (limited to 'PICA_client.c')
-rwxr-xr-xPICA_client.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/PICA_client.c b/PICA_client.c
index fb2353e..2675ae7 100755
--- a/PICA_client.c
+++ b/PICA_client.c
@@ -142,7 +142,9 @@ chnl->conn=ci;
chnl->outgoing=is_outgoing;
chnl->peer_id=uid;
-chnl->sck_data = -1;//prevent closing stdin when closing not active connection
+chnl->timestamp = time(0);
+
+chnl->sck_data = -1;//prevent closing stdin when closing non-active connection
chnl->read_buf = calloc(PICA_CHANREADBUFSIZE, 1);
@@ -932,7 +934,18 @@ while(ipt)
nfds=ipt->sck_data;
}
+ if (ipt->state != PICA_CHANSTATE_ACTIVE && (time(0) - ipt->timestamp) > PICA_CHAN_ACTIVATE_TIMEOUT)
+ {
+ kill_ptr = ipt;
+ }
+
ipt=ipt->next;
+
+ if (kill_ptr)
+ {
+ PICA_close_channel(kill_ptr);
+ kill_ptr = 0;
+ }
}
//#warning "make sockets non-blocking!!!!"
@@ -962,8 +975,8 @@ if (ret>0)
}
- ipt=ipt->next;
-
+ ipt=ipt->next;
+
if (kill_ptr)
{
PICA_close_channel(kill_ptr);