some code tweaks for old compilers

This commit is contained in:
hyung-hwan 2022-06-17 05:35:30 +00:00
parent c39960c9f4
commit afecc741e8
4 changed files with 21 additions and 3 deletions

View File

@ -965,8 +965,8 @@ if (hio_htre_getcontentlen(req) > 0)
} }
else else
{
#endif #endif
{
const hio_bch_t* qpath = hio_htre_getqpath(req); const hio_bch_t* qpath = hio_htre_getqpath(req);
int x; int x;
if (hio_comp_bcstr_limited(qpath, "/thr/", 5, 1) == 0) if (hio_comp_bcstr_limited(qpath, "/thr/", 5, 1) == 0)
@ -978,6 +978,10 @@ if (hio_htre_getcontentlen(req) > 0)
else else
x = hio_svc_htts_dofile(htts, csck, req, "", hio_htre_getqpath(req), "text/plain"); x = hio_svc_htts_dofile(htts, csck, req, "", hio_htre_getqpath(req), "text/plain");
if (x <= -1) goto oops; if (x <= -1) goto oops;
}
#if 0
}
#endif
return 0; return 0;

View File

@ -191,8 +191,8 @@ if (hio_htre_getcontentlen(req) > 0)
} }
else else
{
#endif #endif
{
const hio_bch_t* qpath = hio_htre_getqpath(req); const hio_bch_t* qpath = hio_htre_getqpath(req);
int x; int x;
if (hio_comp_bcstr_limited(qpath, "/thr/", 5, 1) == 0) if (hio_comp_bcstr_limited(qpath, "/thr/", 5, 1) == 0)
@ -206,6 +206,10 @@ if (hio_htre_getcontentlen(req) > 0)
else else
x = hio_svc_htts_dofile(htts, csck, req, "", hio_htre_getqpath(req), "text/plain"); x = hio_svc_htts_dofile(htts, csck, req, "", hio_htre_getqpath(req), "text/plain");
if (x <= -1) goto oops; if (x <= -1) goto oops;
}
#if 0
}
#endif
return 0; return 0;
@ -415,12 +419,13 @@ static int try_to_accept (hio_dev_sck_t* sck, hio_dev_sck_qxmsg_t* qxmsg, int in
} }
else else
{ {
const char* msg;
sidechan_write_error: sidechan_write_error:
//printf ("sidechannel write error errno=%d strerror=%s\n", errno, strerror(errno)); //printf ("sidechannel write error errno=%d strerror=%s\n", errno, strerror(errno));
hio_skadtobcstr (hio, &qxmsg->remoteaddr, buf, HIO_COUNTOF(buf), HIO_SKAD_TO_BCSTR_ADDR | HIO_SKAD_TO_BCSTR_PORT); hio_skadtobcstr (hio, &qxmsg->remoteaddr, buf, HIO_COUNTOF(buf), HIO_SKAD_TO_BCSTR_ADDR | HIO_SKAD_TO_BCSTR_PORT);
HIO_INFO2 (hio, "unable to handle the accepted connection %ld from %hs\n", (long int)qxmsg->syshnd, buf); HIO_INFO2 (hio, "unable to handle the accepted connection %ld from %hs\n", (long int)qxmsg->syshnd, buf);
const char* msg = "HTTP/1.0 503 Service unavailable\r\nConnection: close\r\nContent-Length: 0\r\n\r\n"; msg = "HTTP/1.0 503 Service unavailable\r\nConnection: close\r\nContent-Length: 0\r\n\r\n";
write (qxmsg->syshnd, msg, strlen(msg)); write (qxmsg->syshnd, msg, strlen(msg));
printf ("close %d\n", qxmsg->syshnd); printf ("close %d\n", qxmsg->syshnd);
close (qxmsg->syshnd); close (qxmsg->syshnd);

View File

@ -567,10 +567,17 @@ static HIO_INLINE int process_range_header (file_t* file, hio_htre_t* req)
if (file->req_method == HIO_HTTP_GET) if (file->req_method == HIO_HTTP_GET)
{ {
#if defined(HAVE_STRUCT_STAT_MTIM)
etag_len = hio_fmt_uintmax_to_bcstr(&file->peer_etag[0], HIO_COUNTOF(file->peer_etag), st.st_mtim.tv_sec, 16, -1, '\0', HIO_NULL); etag_len = hio_fmt_uintmax_to_bcstr(&file->peer_etag[0], HIO_COUNTOF(file->peer_etag), st.st_mtim.tv_sec, 16, -1, '\0', HIO_NULL);
file->peer_etag[etag_len++] = '-'; file->peer_etag[etag_len++] = '-';
#if defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
etag_len += hio_fmt_uintmax_to_bcstr(&file->peer_etag[etag_len], HIO_COUNTOF(file->peer_etag), st.st_mtim.tv_nsec, 16, -1, '\0', HIO_NULL); etag_len += hio_fmt_uintmax_to_bcstr(&file->peer_etag[etag_len], HIO_COUNTOF(file->peer_etag), st.st_mtim.tv_nsec, 16, -1, '\0', HIO_NULL);
file->peer_etag[etag_len++] = '-'; file->peer_etag[etag_len++] = '-';
#endif
#else
etag_len = hio_fmt_uintmax_to_bcstr(&file->peer_etag[0], HIO_COUNTOF(file->peer_etag), st.st_mtime, 16, -1, '\0', HIO_NULL);
file->peer_etag[etag_len++] = '-';
#endif
etag_len += hio_fmt_uintmax_to_bcstr(&file->peer_etag[etag_len], HIO_COUNTOF(file->peer_etag) - etag_len, st.st_size, 16, -1, '\0', HIO_NULL); etag_len += hio_fmt_uintmax_to_bcstr(&file->peer_etag[etag_len], HIO_COUNTOF(file->peer_etag) - etag_len, st.st_size, 16, -1, '\0', HIO_NULL);
file->peer_etag[etag_len++] = '-'; file->peer_etag[etag_len++] = '-';
etag_len += hio_fmt_uintmax_to_bcstr(&file->peer_etag[etag_len], HIO_COUNTOF(file->peer_etag) - etag_len, st.st_ino, 16, -1, '\0', HIO_NULL); etag_len += hio_fmt_uintmax_to_bcstr(&file->peer_etag[etag_len], HIO_COUNTOF(file->peer_etag) - etag_len, st.st_ino, 16, -1, '\0', HIO_NULL);

View File

@ -1235,6 +1235,7 @@ static int dev_sck_ioctl (hio_dev_t* dev, int cmd, void* arg)
if (hio_skad_get_family(&bnd->localaddr) == HIO_AF_INET6) /* getsockopt(rdev->hnd, SO_DOMAIN, ...) may return the domain but it's kernel specific as well */ if (hio_skad_get_family(&bnd->localaddr) == HIO_AF_INET6) /* getsockopt(rdev->hnd, SO_DOMAIN, ...) may return the domain but it's kernel specific as well */
{ {
#if defined(IPV6_V6ONLY)
/* TODO: should i make it into bnd->options? HIO_DEV_SCK_BIND_IPV6ONLY? applicable to ipv6 though. */ /* TODO: should i make it into bnd->options? HIO_DEV_SCK_BIND_IPV6ONLY? applicable to ipv6 though. */
int v = 1; int v = 1;
if (setsockopt(rdev->hnd, IPPROTO_IPV6, IPV6_V6ONLY, &v, HIO_SIZEOF(v)) <= -1) if (setsockopt(rdev->hnd, IPPROTO_IPV6, IPV6_V6ONLY, &v, HIO_SIZEOF(v)) <= -1)
@ -1245,6 +1246,7 @@ static int dev_sck_ioctl (hio_dev_t* dev, int cmd, void* arg)
return -1; return -1;
} }
} }
#endif
} }
if (bnd->options & HIO_DEV_SCK_BIND_BROADCAST) if (bnd->options & HIO_DEV_SCK_BIND_BROADCAST)