#include "irc.h"
#include "ircfmt.h"
#include <stdbool.h>
+#ifndef _WIN32
+#include <poll.h>
+#endif
struct client_data *allocClient(){
struct client_data *NewClient = malloc(sizeof(struct client_data));
free(cl);
}
+#if HAS_TLS
+static void block(struct client_data *cl, int out)
+{
+#ifdef _WIN32
+ fd_set fds;
+ FD_ZERO(&fds);
+ FD_SET(cl->FD, &fds);
+ if (out)
+ select(cl->FD+1, 0, &fds, 0, 0);
+ else
+ select(cl->FD+1, &fds, 0, 0, 0);
+#else
+ struct pollfd pfd;
+ pfd.fd = cl->FD;
+ pfd.events = out ? POLLOUT : POLLIN;
+ poll(&pfd, 1, 0);
+#endif
+}
+#endif
+
void recvProc(struct client_data *cl) {
ssize_t bytesRead;
char *x;
case TLS_WANT_POLLIN:
return;
case TLS_WANT_POLLOUT: // FIXME: this blocks
+ block(cl, 1);
continue;
}
}
break;
if (rv == -1)
break;
- if (rv == TLS_WANT_POLLIN || rv == TLS_WANT_POLLOUT)
+ if (rv == TLS_WANT_POLLIN || rv == TLS_WANT_POLLOUT) {
+ block(cl, rv == TLS_WANT_POLLOUT);
continue;
+ }
buf += rv;
len -= rv;
}