From: Matteo Nastasi Date: Sat, 14 Mar 2020 15:29:25 +0000 (+0100) Subject: disabled logging by #define X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=67cfbe1a1e64de87d22aa1bff721b93c11497a8e;p=php-ancillary.git disabled logging by #define --- diff --git a/php-ancillary.c b/php-ancillary.c index b79a92a..635a45b 100644 --- a/php-ancillary.c +++ b/php-ancillary.c @@ -33,7 +33,13 @@ #define PHP_ANCILLARY_VERSION "1.0" #define PHP_ANCILLARY_EXTNAME "ancillary" - + +/* log on stdout */ +/* #define AO_STDLOG 1 */ + +/* log on /tmp/fd_recv.log */ +/* #define AO_TMPLOG 1 */ + extern zend_module_entry ancillary_module_entry; #define phpext_ancillary_ptr &ancillary_module_entry @@ -97,7 +103,8 @@ ancil_recv_fds_with_buffer_ext(int sock, int *fds, unsigned n_fds, void *buffer, if((mop_len = recvmsg(sock, &msghdr, 0)) < 0) return(-1); - if (0 == 1) { +#ifdef AO_TMPLOG + { int mop_fd; char mop_bf[512]; @@ -107,6 +114,7 @@ ancil_recv_fds_with_buffer_ext(int sock, int *fds, unsigned n_fds, void *buffer, close(mop_fd); } +#endif for(i = 0; i < n_fds; i++) fds[i] = ((int *)CMSG_DATA(cmsg))[i]; // n_fds = (cmsg->cmsg_len - sizeof(struct cmsghdr)) / sizeof(int); @@ -213,14 +221,19 @@ PHP_FUNCTION(ancillary_getstream) RETURN_FALSE; } +#ifdef AO_STDLOG { char bf[2048]; sprintf(bf, "zero: [%d] uno: [%d]\n", fd_out[0], fd_out[1]); write(1, bf, strlen(bf)); } +#endif + while(1) { +#ifdef AO_STDLOG write(1, "LOOP\n", 5); +#endif retrecv = recv(fd_out[1], &(headers[curpos]), CTRL_BUFF_MAX_SZ - curpos - 1, 0); if (retrecv < 0) { free(headers); @@ -232,8 +245,10 @@ PHP_FUNCTION(ancillary_getstream) else { char bf[1024]; curpos += retrecv; +#ifdef AO_STDLOG sprintf(bf, "CURPOS: %d\n", curpos); write(1, bf, strlen(bf)); +#endif if (curpos == CTRL_BUFF_MAX_SZ - 1) { free(headers); RETURN_FALSE; @@ -242,14 +257,19 @@ PHP_FUNCTION(ancillary_getstream) } shutdown(fd_out[1], SHUT_RDWR); close(fd_out[1]); +#ifdef AO_STDLOG write(1, "HEADERS[", 8); write(1, headers, curpos); +#endif headers[curpos] = '\0'; +#ifdef AO_STDLOG write(1, "]\n", 2); +#endif ZVAL_STRING(zheaders, headers, 1); free(headers); - if (0 == 1) { +#ifdef AO_TMPLOG + { int fh; if ((fh = open("/tmp/out_php-anc.txt", O_WRONLY | O_CREAT | O_APPEND)) > -1) { @@ -257,6 +277,7 @@ PHP_FUNCTION(ancillary_getstream) close(fh); } } +#endif sock = pemalloc(sizeof(php_netstream_data_t), 0); memset(sock, 0, sizeof(php_netstream_data_t));