projects
/
php-ancillary.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
7b28939
)
disabled logging by #define
no-more-log
author
Matteo Nastasi
<nastasi@alternativeoutput.it>
Sat, 14 Mar 2020 15:29:25 +0000
(16:29 +0100)
committer
Matteo Nastasi
<nastasi@alternativeoutput.it>
Sat, 14 Mar 2020 15:29:25 +0000
(16:29 +0100)
php-ancillary.c
patch
|
blob
|
history
diff --git
a/php-ancillary.c
b/php-ancillary.c
index
b79a92a
..
635a45b
100644
(file)
--- a/
php-ancillary.c
+++ b/
php-ancillary.c
@@
-33,7
+33,13
@@
#define PHP_ANCILLARY_VERSION "1.0"
#define PHP_ANCILLARY_EXTNAME "ancillary"
#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
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((mop_len = recvmsg(sock, &msghdr, 0)) < 0)
return(-1);
- if (0 == 1) {
+#ifdef AO_TMPLOG
+ {
int mop_fd;
char mop_bf[512];
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);
}
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);
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;
}
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));
}
{
char bf[2048];
sprintf(bf, "zero: [%d] uno: [%d]\n", fd_out[0], fd_out[1]);
write(1, bf, strlen(bf));
}
+#endif
+
while(1) {
while(1) {
+#ifdef AO_STDLOG
write(1, "LOOP\n", 5);
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);
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;
else {
char bf[1024];
curpos += retrecv;
+#ifdef AO_STDLOG
sprintf(bf, "CURPOS: %d\n", curpos);
write(1, bf, strlen(bf));
sprintf(bf, "CURPOS: %d\n", curpos);
write(1, bf, strlen(bf));
+#endif
if (curpos == CTRL_BUFF_MAX_SZ - 1) {
free(headers);
RETURN_FALSE;
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]);
}
shutdown(fd_out[1], SHUT_RDWR);
close(fd_out[1]);
+#ifdef AO_STDLOG
write(1, "HEADERS[", 8);
write(1, headers, curpos);
write(1, "HEADERS[", 8);
write(1, headers, curpos);
+#endif
headers[curpos] = '\0';
headers[curpos] = '\0';
+#ifdef AO_STDLOG
write(1, "]\n", 2);
write(1, "]\n", 2);
+#endif
ZVAL_STRING(zheaders, headers, 1);
free(headers);
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) {
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);
}
}
close(fh);
}
}
+#endif
sock = pemalloc(sizeof(php_netstream_data_t), 0);
memset(sock, 0, sizeof(php_netstream_data_t));
sock = pemalloc(sizeof(php_netstream_data_t), 0);
memset(sock, 0, sizeof(php_netstream_data_t));