#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
if((mop_len = recvmsg(sock, &msghdr, 0)) < 0)
return(-1);
- if (0 == 1) {
+#ifdef AO_TMPLOG
+ {
int mop_fd;
char mop_bf[512];
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);
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);
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;
}
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) {
close(fh);
}
}
+#endif
sock = pemalloc(sizeof(php_netstream_data_t), 0);
memset(sock, 0, sizeof(php_netstream_data_t));