aboutsummaryrefslogtreecommitdiffstats
path: root/src/libtipidee/tipidee_fcgi_read.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2026-07-06 09:16:00 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2026-07-06 09:16:00 +0000
commitb39ac47f1977ec9ea58b4281673e3393e60fc8e8 (patch)
treebed31a0be1ae396b617498dfbbc5b707c2b3b97c /src/libtipidee/tipidee_fcgi_read.c
parent1b60f4b310419f315433b1c83ff1e7e035824f8b (diff)
downloadtipidee-b39ac47f1977ec9ea58b4281673e3393e60fc8e8.tar.gz
First debug session
Diffstat (limited to 'src/libtipidee/tipidee_fcgi_read.c')
-rw-r--r--src/libtipidee/tipidee_fcgi_read.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/libtipidee/tipidee_fcgi_read.c b/src/libtipidee/tipidee_fcgi_read.c
index 9b6dcb0..c185724 100644
--- a/src/libtipidee/tipidee_fcgi_read.c
+++ b/src/libtipidee/tipidee_fcgi_read.c
@@ -7,6 +7,7 @@
#include <skalibs/uint32.h>
#include <skalibs/stralloc.h>
#include <skalibs/unix-timed.h>
+#include <skalibs/lolstdio.h>
#include <tipidee/fcgi.h>
@@ -18,19 +19,23 @@ int tipidee_fcgi_read (tipidee_fcgi *fc, uint32_t *status, stralloc *sa, tain *s
uint16_t u ;
char hdr[8] ;
if (buffer_timed_get(&fc->b, hdr, 8, &fc->deadline, stamp) < 8) return -1 ;
+ LOLDEBUG("reading a header: version is %hhu - type is %hhu", hdr[0], hdr[1]) ;
if (hdr[0] != 1) return (errno = EPROTO, -1) ;
uint16_unpack_big(hdr + 2, &u) ;
+ LOLDEBUG(" id is %hu, client's was %hu", u, fc->id) ;
if (u != fc->id) return (errno = EPROTO, -1) ;
uint16_unpack_big(hdr + 4, &u) ;
+ LOLDEBUG("payload length is %hu", u) ;
switch (hdr[1])
{
- case FCGI_STDOUT : stream = 1 ;
- case FCGI_STDERR : stream = 2 ;
- case FCGI_END_REQUEST : stream = 0 ;
+ case FCGI_STDOUT : stream = 1 ; break ;
+ case FCGI_STDERR : stream = 2 ; break ;
+ case FCGI_END_REQUEST : stream = 0 ; break ;
default : return (errno = EPROTO, -1) ;
}
if (stream)
{
+ LOLDEBUG("stream is %d - reading %hu bytes", stream, u) ;
if (!stralloc_readyplus(sa, u)) return -1 ;
if (buffer_timed_get(&fc->b, sa->s + sa->len, u, &fc->deadline, stamp) < u) return -1 ;
sa->len += u ;
@@ -38,6 +43,7 @@ int tipidee_fcgi_read (tipidee_fcgi *fc, uint32_t *status, stralloc *sa, tain *s
else
{
char endreq[8] ;
+ LOLDEBUG("end request detected, %hu bytes", u) ;
if (u != 8) return (errno = EPROTO, -1) ;
if (buffer_timed_get(&fc->b, endreq, 8, &fc->deadline, stamp) < 8) return -1 ;
switch (endreq[4])
@@ -53,7 +59,8 @@ int tipidee_fcgi_read (tipidee_fcgi *fc, uint32_t *status, stralloc *sa, tain *s
if (hdr[6])
{
char tmp[(uint8_t)hdr[6]] ;
- if (buffer_timed_get(&fc->b, tmp, (uint8_t)hdr[6], &fc->deadline, stamp)) return -1 ;
+ LOLDEBUG("reading %hhu bytes of padding", (uint8_t)hdr[6]) ;
+ if (buffer_timed_get(&fc->b, tmp, (uint8_t)hdr[6], &fc->deadline, stamp) < (uint8_t)hdr[6]) return -1 ;
}
return stream ;
}