Update to latest (nw)

This commit is contained in:
Miodrag Milanovic 2014-06-16 06:38:30 +00:00
parent 0cdb4bdb14
commit dd8c59687f
2 changed files with 10 additions and 3 deletions

View File

@ -271,8 +271,6 @@ static int ev_handler(struct mg_connection *conn, enum mg_event ev) {
// This handler is called for each incoming websocket frame, one or more
// times for connection lifetime.
// Echo websocket data back to the client.
//const char *msg = "update_machine";
//mg_websocket_write(conn, 1, msg, strlen(msg));
return conn->content_len == 4 && !memcmp(conn->content, "exit", 4) ? MG_FALSE : MG_TRUE;
} else {
web_engine *engine = static_cast<web_engine *>(conn->server_param);

View File

@ -548,6 +548,12 @@ static sock_t ns_open_listening_socket(union socket_address *sa) {
if ((sock = socket(sa->sa.sa_family, SOCK_STREAM, 6)) != INVALID_SOCKET &&
#ifndef _WIN32
// SO_RESUSEADDR is not enabled on Windows because the semantics of
// SO_REUSEADDR on UNIX and Windows is different. On Windows,
// SO_REUSEADDR allows to bind a socket to a port without error even if
// the port is already open by another program. This is not the behavior
// SO_REUSEADDR was designed for, and leads to hard-to-track failure
// scenarios. Therefore, SO_REUSEADDR was disabled on Windows.
!setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &on, sizeof(on)) &&
#endif
!bind(sock, &sa->sa, sa->sa.sa_family == AF_INET ?
@ -4931,7 +4937,10 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
case NS_POLL:
if (call_user(conn, MG_POLL) == MG_TRUE) {
nc->flags |= NSF_FINISHED_SENDING_DATA;
if (conn->ns_conn->flags & MG_HEADERS_SENT) {
write_terminating_chunk(conn);
}
close_local_endpoint(conn);
}
if (conn != NULL && conn->endpoint_type == EP_FILE) {