bool CHttpServer::process(SOCKET sock) { m_sock = sock; // First of all, make socket non-blocking #if defined(WINDOWS_PLATFORM) unsigned long optval = 1; if(::ioctlsocket(m_sock, FIONBIO, &optval) == SOCKET_ERROR) { if (verbose) RAWLOG_ERROR1("Can not set non-blocking socket mode: %d", RHO_NET_ERROR_CODE); return false; } #else int flags = fcntl(m_sock, F_GETFL); if (flags == -1) { if (verbose) RAWLOG_ERROR1("Can not get current socket mode: %d", errno); return false; } if (fcntl(m_sock, F_SETFL, flags | O_NONBLOCK) == -1) { if (verbose) RAWLOG_ERROR1("Can not set non-blocking socket mode: %d", errno); return false; } #endif // Read request from socket ByteVector request; String method, uri, query; HeaderList headers; String body; if (!parse_request(method, uri, query, headers, body)) { if (verbose) RAWLOG_ERROR("Parsing error"); send_response(create_response("500 Internal Error")); return false; } if ( !String_endsWith( uri, "js_api_entrypoint" ) ) if (verbose) RAWLOG_INFO1("Process URI: '%s'", uri.c_str()); return decide(method, uri, query, headers, body); }
VALUE require_compiled(VALUE fname, VALUE* result, int bLoad) { VALUE path; char* szName1 = 0; VALUE retval = Qtrue; if (TYPE(fname) != T_STRING) rb_raise(rb_eLoadError, "can not load non-string"); szName1 = RSTRING_PTR(fname); if ( String_endsWith(szName1,".rb") ) { rb_str_chop_bang(fname); rb_str_chop_bang(fname); rb_str_chop_bang(fname); } //rb_funcall(fname, rb_intern("sub!"), 2, rb_str_new2(".rb"), rb_str_new2("") ); szName1 = RSTRING_PTR(fname); if ( strcmp("strscan",szName1)==0 || strcmp("enumerator",szName1)==0 || strcmp("stringio",szName1)==0 || strcmp("socket",szName1)==0 ) return Qtrue; RHO_LOCK(require_lock); if ( !bLoad && isAlreadyLoaded(fname) == Qtrue ) goto RCompExit; path = find_file(fname); if ( path != 0 ) { VALUE seq; RAWLOG_INFO1("require_compiled: %s", szName1); //optimize require //rb_ary_push(GET_VM()->loaded_features, path); rb_ary_push(GET_VM()->loaded_features, fname); #ifdef RHODES_EMULATOR if ( strstr( RSTRING_PTR(path), ".rb") == 0 ) rb_str_cat(path,".rb",3); GET_VM()->src_encoding_index = rb_utf8_encindex(); rb_load(path, 0); if( rho_simconf_getBool("reload_app_changes") ) { if ( strncmp( RSTRING_PTR(path), rho_native_rhopath(), strlen(rho_native_rhopath()) ) == 0 ) rb_ary_delete(GET_VM()->loaded_features, fname); } #else //rb_gc_disable(); seq = loadISeqFromFile(path); //*result = rb_funcall(seq, rb_intern("eval"), 0 ); *result = rb_iseq_eval(seq); //rb_gc_enable(); #endif goto RCompExit; } RAWLOG_ERROR1("require_compiled: error: can not find %s", RSTRING_PTR(fname)); retval = Qnil; RCompExit: RHO_UNLOCK(require_lock); return retval; }