Skip to content

Commit

Permalink
Added protocolUseTcp2PKeepAlive to keep the socket alive after use
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-selo authored Nov 21, 2016
1 parent 17d90b1 commit 1518dbd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/ext/oblivc/obliv_bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typedef struct tcp2PTransport
bool isClient;
FILE* sockStream;
bool needFlush;
bool keepAlive;
int sinceFlush;
#ifdef PROFILE_NETWORK
size_t bytes;
Expand Down Expand Up @@ -138,7 +139,8 @@ static void tcp2PCleanup(ProtocolTransport* pt)
{
tcp2PTransport* t = CAST(pt);
fflush(t->sockStream);
fclose(t->sockStream);
if(!t->keepAlive)
fclose(t->sockStream);
#ifdef PROFILE_NETWORK
t->flushCount++;
if(t->parent==NULL)
Expand Down Expand Up @@ -192,7 +194,19 @@ static tcp2PTransport* tcp2PNew(int sock,bool isClient)
return trans;
}
void protocolUseTcp2P(ProtocolDesc* pd,int sock,bool isClient)
{ pd->trans = &tcp2PNew(sock,isClient)->cb; }
{
pd->trans = &tcp2PNew(sock,isClient)->cb;
tcp2PTransport* t = CAST(pd->trans);
t->keepAlive = false;
}


void protocolUseTcp2PKeepAlive(ProtocolDesc* pd,int sock,bool isClient)
{
pd->trans = &tcp2PNew(sock,isClient)->cb;
tcp2PTransport* t = CAST(pd->trans);
t->keepAlive = true;
}

static int getsockaddr(const char* name,const char* port, struct sockaddr* res)
{
Expand Down

0 comments on commit 1518dbd

Please sign in to comment.