Permalink
Browse files

socket cleanup

  • Loading branch information...
1 parent 76e1377 commit 3f540a0a774a107528088a625fd8eeb8a2c8ef01 @sugendran sugendran committed Dec 13, 2012
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
@@ -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
@@ -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,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

0 comments on commit 3f540a0

Please sign in to comment.