Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

socket cleanup

  • Loading branch information...
commit 3f540a0a774a107528088a625fd8eeb8a2c8ef01 1 parent 76e1377
@sugendran sugendran authored
Showing with 9 additions and 5 deletions.
  1. +3 −2 graphdat.c
  2. +5 −2 src/sockets.c
  3. +1 −1  src/sockets.h
View
5 graphdat.c
@@ -191,7 +191,7 @@ PHP_MSHUTDOWN_FUNCTION(graphdat)
{
if(GRAPHDAT_GLOBALS(socketFD) != -1)
{
- closeSocket(GRAPHDAT_GLOBALS(socketFD));
+ closeSocket(GRAPHDAT_GLOBALS(socketFD), GRAPHDAT_GLOBALS(debug));
GRAPHDAT_GLOBALS(socketFD) = -1;
}
@@ -417,8 +417,9 @@ static void onRequestEnd(TSRMLS_D)
if(written != 4)
{
// close and reopen in case there is a broken pipe
- closeSocket(GRAPHDAT_GLOBALS(socketFD));
+ closeSocket(GRAPHDAT_GLOBALS(socketFD), GRAPHDAT_GLOBALS(debug));
GRAPHDAT_GLOBALS(socketFD) = -1;
+ PRINTDEBUG("Retrying the write");
GRAPHDAT_GLOBALS(socketFD) = openSocket(GRAPHDAT_GLOBALS(socketFile), (int) GRAPHDAT_GLOBALS(socketPort), GRAPHDAT_GLOBALS(debug));
written = socketWrite(GRAPHDAT_GLOBALS(socketFD), &len, 4, GRAPHDAT_GLOBALS(debug));
}
View
7 src/sockets.c
@@ -51,10 +51,13 @@ int openSocket(char *path, int port, int debug)
return sockfd;
}
-void closeSocket(int sockfd)
+void closeSocket(int sockfd, int debug)
{
close(sockfd);
- zend_error(E_NOTICE, "Graphdat :: socket %d closed\n", sockfd);
+ if(debug)
+ {
+ zend_error(E_NOTICE, "Graphdat :: socket %d closed\n", sockfd);
+ }
}
int socketWrite(int sockfd, void* buf, int len, int debug)
View
2  src/sockets.h
@@ -2,7 +2,7 @@
#define GRAPHDAT_SOCKETS_H
int openSocket(char *path, int port, int debug);
-void closeSocket(int sockfd);
+void closeSocket(int sockfd, int debug);
int socketWrite(int sockfd, void* buf, int len, int debug);
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.