aboutsummaryrefslogtreecommitdiff
path: root/src/serverlist.cpp
Commit message (Expand)AuthorAge
* Print announce error response (#11878)ShadowNinja2022-01-01
* Use JSON for favorites, move server list code to Lua (#10085)rubenwardy2021-01-22
* Log server announce on updates and deletes too (#10177)Tyler Schwend2020-09-26
* Clean up server-side translations, remove global variable (#10075)rubenwardy2020-09-16
* Add PUT and DELETE request + specific method value to HTTP API (#9909)Lejo2020-07-29
* Make core.get_favorites("local") ignore duplicates (#7926)Paul Ouellette2019-11-08
* Update JsonCPP to 1.8.3 (#6466)Loïc Blot2017-09-26
* Network: Remove large parts of deprecated legacy code (#6404)SmallJoker2017-09-12
* Code modernization: src/p*, src/q*, src/r*, src/s* (partial) (#6282)Loïc Blot2017-08-19
* Server list cleanupShadowNinja2017-03-18
* Fixes for compiling with a newer (system) jsoncpp (#4429)Rogier-52016-08-10
* Add option to not send pre v25 init packetest312016-03-15
* Change i++ to ++iDavid Jones2015-08-25
* Move globals from main.cpp to more sane locationsCraig Robbins2015-04-01
* Clean up and tweak build systemShadowNinja2015-03-27
* Server: announce MIN/MAX protocol version supported to serverlist. Client: ch...est312015-02-18
* Send real port to server listShadowNinja2015-01-23
* Serverlist: announce mg_name from map_meta.txt instead of minetest.confKahrl2014-11-10
* Replace setting unlimited_player_transfer_distance with player_transfer_distanceSmallJoker2014-11-08
* Reduce indentation of HTTPFetchOngoingShadowNinja2014-09-18
* Fix serverlist code style, const-correctness, and typesShadowNinja2014-06-30
* Fix server list boolean typing and alignmentShadowNinja2014-06-30
* Add support for multipart/form-data to HTTPFetch for server announcingShadowNinja2014-06-30
* Remove ugly curl struct pointer from jsonFetchValue signaturesapier2014-06-19
* Remove a lot of superfluous ifndef USE_CURL checkssapier2014-06-19
* Remove liquid_finite and weatherproller2014-04-18
* Fix wrong named masterserver announce variableproller2014-01-07
* Send long announce as POST, show OS in useragentproller2014-01-07
* Use httpfetch_async in serverlist announce codeKahrl2013-12-13
* Rename names -> can_see_far_names in announceproller2013-12-03
* Remove link to #, add unlimited_player_transfer_distance to announceproller2013-12-03
* Correct useragent in http queriesproller2013-11-06
* Masterserver show privs and js autoloadproller2013-11-04
* Masterserver updateproller2013-10-18
* Show git hash in version string at top left corner of windowKahrl2013-09-28
* Dont write directly to files but rather write and copy a tmp filePilzAdam2013-08-13
* More info in serverlistproller2013-08-03
* Masterserver mods announse, ipv6, better curl errorsproller2013-07-13
* Replace C++ mainmenu by formspec powered onesapier2013-07-02
* Fix favorite Server List on WindowsSfan52013-05-04
* Fix serverlist on -DRUN_IN_PLACE=0 (use path_user instead of path_share)Zeg92013-04-25
* Masterserver: report gameid, uptime, cosmetic fixes on server web pageproller2013-03-30
* Add one more curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);Ilya Zhuravlev2013-03-03
* Fix "longjmp causes uninitialized stack frame" (serverlist.cpp)Ilya Zhuravlev2013-03-01
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* new auto masterserverproller2013-02-22
* Add a list of servers to the "Multiplayer" tabJeija2013-01-21
disable_stderr) g_debugstreams[0] = NULL; else g_debugstreams[0] = stderr; if(filename) g_debugstreams[1] = fopen(filename, "a"); if(g_debugstreams[1]) { fprintf(g_debugstreams[1], "\n\n-------------\n"); fprintf(g_debugstreams[1], " Separator \n"); fprintf(g_debugstreams[1], "-------------\n\n"); } } void debugstreams_deinit() { if(g_debugstreams[1] != NULL) fclose(g_debugstreams[1]); } class Debugbuf : public std::streambuf { public: Debugbuf(bool disable_stderr) { m_disable_stderr = disable_stderr; } int overflow(int c) { for(int i=0; i<DEBUGSTREAM_COUNT; i++) { if(g_debugstreams[i] == stderr && m_disable_stderr) continue; if(g_debugstreams[i] != NULL) (void)fwrite(&c, 1, 1, g_debugstreams[i]); //TODO: Is this slow? fflush(g_debugstreams[i]); } return c; } std::streamsize xsputn(const char *s, std::streamsize n) { for(int i=0; i<DEBUGSTREAM_COUNT; i++) { if(g_debugstreams[i] == stderr && m_disable_stderr) continue; if(g_debugstreams[i] != NULL) (void)fwrite(s, 1, n, g_debugstreams[i]); //TODO: Is this slow? fflush(g_debugstreams[i]); } return n; } private: bool m_disable_stderr; }; Debugbuf debugbuf(false); std::ostream dstream(&debugbuf); Debugbuf debugbuf_no_stderr(true); std::ostream dstream_no_stderr(&debugbuf_no_stderr); Nullstream dummyout; /* Assert */ void assert_fail(const char *assertion, const char *file, unsigned int line, const char *function) { DEBUGPRINT("\nIn thread %lx:\n" "%s:%d: %s: Assertion '%s' failed.\n", (unsigned long)get_current_thread_id(), file, line, function, assertion); debug_stacks_print(); if(g_debugstreams[1]) fclose(g_debugstreams[1]); abort(); } /* DebugStack */ struct DebugStack { DebugStack(threadid_t id); void print(FILE *file, bool everything); void print(std::ostream &os, bool everything); threadid_t threadid; char stack[DEBUG_STACK_SIZE][DEBUG_STACK_TEXT_SIZE]; int stack_i; // Points to the lowest empty position int stack_max_i; // Highest i that was seen }; DebugStack::DebugStack(threadid_t id) { threadid = id; stack_i = 0; stack_max_i = 0; memset(stack, 0, DEBUG_STACK_SIZE*DEBUG_STACK_TEXT_SIZE); } void DebugStack::print(FILE *file, bool everything) { fprintf(file, "DEBUG STACK FOR THREAD %lx:\n", (unsigned long)threadid); for(int i=0; i<stack_max_i; i++) { if(i == stack_i && everything == false) break; if(i < stack_i) fprintf(file, "#%d %s\n", i, stack[i]); else fprintf(file, "(Leftover data: #%d %s)\n", i, stack[i]); } if(stack_i == DEBUG_STACK_SIZE) fprintf(file, "Probably overflown.\n"); } void DebugStack::print(std::ostream &os, bool everything) { os<<"DEBUG STACK FOR THREAD "<<(unsigned long)threadid<<": "<<std::endl; for(int i=0; i<stack_max_i; i++) { if(i == stack_i && everything == false) break; if(i < stack_i) os<<"#"<<i<<" "<<stack[i]<<std::endl; else os<<"(Leftover data: #"<<i<<" "<<stack[i]<<")"<<std::endl; } if(stack_i == DEBUG_STACK_SIZE) os<<"Probably overflown."<<std::endl; } std::map<threadid_t, DebugStack*> g_debug_stacks; JMutex g_debug_stacks_mutex; void debug_stacks_init() { } void debug_stacks_print_to(std::ostream &os) { JMutexAutoLock lock(g_debug_stacks_mutex); os<<"Debug stacks:"<<std::endl; for(std::map<threadid_t, DebugStack*>::iterator i = g_debug_stacks.begin(); i != g_debug_stacks.end(); ++i) { i->second->print(os, false); } } void debug_stacks_print() { JMutexAutoLock lock(g_debug_stacks_mutex); DEBUGPRINT("Debug stacks:\n"); for(std::map<threadid_t, DebugStack*>::iterator i = g_debug_stacks.begin(); i != g_debug_stacks.end(); ++i) { DebugStack *stack = i->second; for(int i=0; i<DEBUGSTREAM_COUNT; i++) { if(g_debugstreams[i] != NULL) stack->print(g_debugstreams[i], true); } } } DebugStacker::DebugStacker(const char *text) { threadid_t threadid = get_current_thread_id(); JMutexAutoLock lock(g_debug_stacks_mutex); std::map<threadid_t, DebugStack*>::iterator n; n = g_debug_stacks.find(threadid); if(n != g_debug_stacks.end()) { m_stack = n->second; } else { /*DEBUGPRINT("Creating new debug stack for thread %x\n", (unsigned int)threadid);*/ m_stack = new DebugStack(threadid); g_debug_stacks[threadid] = m_stack; } if(m_stack->stack_i >= DEBUG_STACK_SIZE) { m_overflowed = true; } else { m_overflowed = false; snprintf(m_stack->stack[m_stack->stack_i], DEBUG_STACK_TEXT_SIZE, "%s", text); m_stack->stack_i++; if(m_stack->stack_i > m_stack->stack_max_i) m_stack->stack_max_i = m_stack->stack_i; } } DebugStacker::~DebugStacker() { JMutexAutoLock lock(g_debug_stacks_mutex); if(m_overflowed == true) return; m_stack->stack_i--; if(m_stack->stack_i == 0) { threadid_t threadid = m_stack->threadid; /*DEBUGPRINT("Deleting debug stack for thread %x\n", (unsigned int)threadid);*/ delete m_stack; g_debug_stacks.erase(threadid); } } #ifdef _MSC_VER #if CATCH_UNHANDLED_EXCEPTIONS == 1 void se_trans_func(unsigned int u, EXCEPTION_POINTERS* pExp) { dstream<<"In trans_func.\n"; if(u == EXCEPTION_ACCESS_VIOLATION) { PEXCEPTION_RECORD r = pExp->ExceptionRecord; dstream<<"Access violation at "<<r->ExceptionAddress <<" write?="<<r->ExceptionInformation[0] <<" address="<<r->ExceptionInformation[1] <<std::endl; throw FatalSystemException ("Access violation"); } if(u == EXCEPTION_STACK_OVERFLOW) { throw FatalSystemException ("Stack overflow"); } if(u == EXCEPTION_ILLEGAL_INSTRUCTION) { throw FatalSystemException ("Illegal instruction"); } } #endif #endif