void ComponentOp2::SetOperator(char op) { ComponentType inType = CT_NONE; if (op == '|' || op == '&') inType = CT_BOOL; else if (op == '=') inType = CT_NONE; else inType = CT_DOUBLE; if (inType == CT_NONE) { for (size_t i = 0; i < m_inputs.size(); i++) { if (m_inputs[i].comp == NULL) m_inputs[i].type = CT_NONE; else inType = m_inputs[i].type; m_inputs[i].dynamic = true; } for (size_t i = 0; i < m_inputs.size(); i++) if (m_inputs[i].dynamic) m_inputs[i].type = inType; } else { for (size_t i = 0; i < m_inputs.size(); i++) if (m_inputs[i].type != inType && inType != CT_NONE) { m_inputs[i].type = inType; m_inputs[i].dynamic = false; RemoveInput(m_inputs[i].comp); } } if (op == '|' || op == '&' || op == '<' || op == '>' || op == '=') { if (m_outputs[0].type != CT_BOOL) ClearOutputs(); m_outputs[0].type = CT_BOOL; } else { if (m_outputs[0].type != CT_DOUBLE) ClearOutputs(); m_outputs[0].type = CT_DOUBLE; } m_operator = op; }
/** * Close the session associated with a particular socket. * Called from the HTTPD logic when a fatal error or EOF occurs. * * @param[in] session Session */ static void hio_socket_close(session_t *session) { SOCK_CLOSE(session->s); if (session->ioid != NULL_IOID) { RemoveInput(session->ioid); } if (session->toid != NULL_IOID) { RemoveTimeOut(session->toid); } #if defined(_WIN32) /*[*/ CloseHandle(session->event); #endif /*]*/ vb_free(&session->pending.result); llist_unlink(&session->link); Free(session); n_sessions--; }
/** * New inbound data for an httpd connection. * * @param[in] fd socket file descriptor * @param[in] id I/O ID */ void hio_socket_input(iosrc_t fd, ioid_t id) { session_t *session; char buf[1024]; ssize_t nr; session = NULL; FOREACH_LLIST(&sessions, session, session_t *) { if (session->ioid == id) { break; } } FOREACH_LLIST_END(&sessions, session, session_t *); if (session == NULL) { vtrace("httpd mystery input\n"); return; } /* Move this session to the front of the list. */ llist_unlink(&session->link); llist_insert_before(&session->link, sessions.next); session->idle = 0; if (session->toid != NULL_IOID) { RemoveTimeOut(session->toid); session->toid = NULL_IOID; } nr = recv(session->s, buf, sizeof(buf), 0); if (nr <= 0) { const char *ebuf; bool harmless = false; if (nr < 0) { if (socket_errno() == SE_EWOULDBLOCK) { harmless = true; } ebuf = lazyaf("recv error: %s", socket_errtext()); vtrace("httpd %s%s\n", ebuf, harmless? " (harmless)": ""); } else { ebuf = "session EOF"; } if (!harmless) { httpd_close(session->dhandle, ebuf); hio_socket_close(session); } } else { httpd_status_t rv; rv = httpd_input(session->dhandle, buf, nr); if (rv < 0) { httpd_close(session->dhandle, "protocol error"); hio_socket_close(session); } else if (rv == HS_PENDING) { /* Stop input on this socket. */ RemoveInput(session->ioid); session->ioid = NULL_IOID; } else if (session->toid == NULL_IOID) { /* Leave input enabled and start the timeout. */ session->toid = AddTimeOut(IDLE_MAX * 1000, hio_timeout); } } }