sp->obj->len = cl;
p = st->ptr;
- i = fcntl(htc->fd, F_GETFL); /* XXX ? */
- i &= ~O_NONBLOCK;
- i = fcntl(htc->fd, F_SETFL, i);
+ TCP_blocking(htc->fd);
while (cl > 0) {
i = HTC_Read(htc, p, cl);
struct storage *st;
unsigned v;
- i = fcntl(htc->fd, F_GETFL); /* XXX ? */
- i &= ~O_NONBLOCK;
- i = fcntl(htc->fd, F_SETFL, i);
+ TCP_blocking(htc->fd);
p = NULL;
v = 0;
void TCP_name(const struct sockaddr *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen);
void TCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen);
int TCP_filter_http(int sock);
+void TCP_blocking(int sock);
+void TCP_nonblocking(int sock);
#define TRUST_ME(ptr) ((void*)(uintptr_t)(ptr))
#include <netinet/in.h>
#include <errno.h>
+#include <fcntl.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
return (0);
#endif
}
+
+/*--------------------------------------------------------------------*/
+
+void
+TCP_blocking(int sock)
+{
+ int i;
+
+ i = fcntl(sock, F_GETFL);
+ assert(i != -1);
+ i &= ~O_NONBLOCK;
+ i = fcntl(sock, F_SETFL, i);
+ assert(i != -1);
+}
+
+void
+TCP_nonblocking(int sock)
+{
+ int i;
+
+ i = fcntl(sock, F_GETFL);
+ assert(i != -1);
+ i |= O_NONBLOCK;
+ i = fcntl(sock, F_SETFL, i);
+ assert(i != -1);
+}