diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lua-interface.cpp | 50 | 
1 files changed, 6 insertions, 44 deletions
| diff --git a/src/lua-interface.cpp b/src/lua-interface.cpp index 8273a05..833eb6b 100644 --- a/src/lua-interface.cpp +++ b/src/lua-interface.cpp @@ -45,7 +45,6 @@  #include <Output.h>  #include <Buffer.h>  #include <BLua.h> -#ifdef HAS_FULL_MULTITHREADING  #include <LuaCommandLine.h>  #include <HttpServ.h>  #include <CopyJob.h> @@ -54,7 +53,6 @@  #include <Form.h>  #include <LuaTask.h>  #include <TaskMan.h> -#endif  #include <BRegex.h>  #include <generic.h>  #include <Main.h> @@ -84,11 +82,9 @@ extern void luaconfigfiles_init(Lua * L) WEAK;  extern void luaftgl_init(Lua * L) WEAK;  extern void luagl_init(Lua * L) WEAK;  extern void luahandle_init(Lua * L) WEAK; -#ifdef HAS_FULL_MULTITHREADING  extern void luahttp_init(Lua * L) WEAK;  extern void luasmtp_init(Lua * L) WEAK;  extern void luatask_init(Lua * L) WEAK; -#endif  extern void lualibs_init(Lua * L) WEAK;  extern void luaocci_init(Lua * L) WEAK;  extern void luaregex_init(Lua * L) WEAK; @@ -233,14 +229,12 @@ class LuaStderrPrinter : public LuaPrinter {  LuaStderrPrinter lp_stderr; -#ifdef HAS_FULL_MULTITHREADING  String server_fname = "server.lua";  static int StartTaskLoop(void * foo) {      TaskMan::MainLoop();      return 0;  } -#endif  static String searchpath; @@ -332,14 +326,12 @@ int sLua_baselua_interface::baselua_interface_proceed_statics(Lua * L, int n, in  #endif          } else if ((filename == "luahandle") && (luahandle_init != NULL)) {              luahandle_init(L); -#ifdef HAS_FULL_MULTITHREADING          } else if ((filename == "luahttp") && (luahttp_init != NULL)) {              luahttp_init(L);          } else if ((filename == "luasmtp") && (luasmtp_init != NULL)) {              luasmtp_init(L);          } else if ((filename == "luatask") && (luatask_init != NULL)) {              luatask_init(L); -#endif          } else if ((filename == "lualibs") && (lualibs_init != NULL)) {              lualibs_init(L);  #ifndef LUA_INTERFACE_LIGHT @@ -463,19 +455,16 @@ struct option long_options[] = {      {"built-in",	0, NULL, 'b'},      {"probe",		0, NULL, 'p'},      {"log",             1, NULL, 'g'}, -#ifdef HAS_FULL_MULTITHREADING      {"mail",            2, NULL, 'm'},      {"server",          2, NULL, 's'},      {"telnet",          2, NULL, 't'},      {"server_fname",    1, NULL, 'f'}, -#endif  #ifdef HAVE_FORK      {"daemonize",	1, NULL, 'z'},  #endif      {0,			0, NULL,  0 }  }; -#ifdef HAS_FULL_MULTITHREADING  String LUACall_Names[] = {"identifier"};  String LUACall_Defaults[] = {""};  String LUACall_Invites[] = {"LUA function name:"}; @@ -520,7 +509,6 @@ Task * LUACall::Do(Variables * v, Variables * headers, Handle * h) {      }      return Message::Do(v, headers, h);  } -#endif  bool auto_exec = true; @@ -605,12 +593,10 @@ void showhelp(bool longhelp = false) {  "  -e <cmd> to execute this single command in LUA.\n"  "  -b       to force the use of the built-in lua-interface.lua\n"  "  -g <log> to log into a file.\n" -#ifdef HAS_FULL_MULTITHREADING  "  -m[mp]   start the mail server on port mp (2500 by default).\n"  "  -s[hp]   start the built-in http server on port hp (1500 by default).\n"  "  -t[tp]   start the telnet server, on port tp (1550 by default).\n"  "  -f <fil> filename of server code to use (server.lua by default).\n" -#endif  #ifdef HAVE_FORK  "  -z       daemonize; incompatible with -i; use with -g.\n"  #endif @@ -670,7 +656,6 @@ static bool runlua(Lua * L, Buffer * command) {      return true;  } -#ifdef HAS_FULL_MULTITHREADING  class PrompterTask : public Task {    public:        PrompterTask(Lua * L) : r(Socket::CreatePair()), w(r.GetPair()), c(0), L(L) { @@ -710,7 +695,6 @@ class PrompterTask : public Task {      Task * c;      Lua * L;  }; -#endif  struct interactive_prompt_data_t {      Lua * L; @@ -808,22 +792,18 @@ void autoload_exports(Lua * L) {          luahandle_init(L);      if (luaconfigfiles_init)          luaconfigfiles_init(L); -#ifdef HAS_FULL_MULTITHREADING      if (luahttp_init)          luahttp_init(L);      if (luasmtp_init)          luasmtp_init(L); -#endif      if (luaregex_init)          luaregex_init(L);  #ifndef LUA_INTERFACE_LIGHT      if (luasql_init)          luasql_init(L);  #endif -#ifdef HAS_FULL_MULTITHREADING      if (luatask_init)          luatask_init(L); -#endif      if (luaxml_init)          luaxml_init(L);  #ifndef LUA_INTERFACE_LIGHT @@ -853,8 +833,8 @@ virtual int startup() throw (GeneralException) {      bool todo = false, write = false, builtin = false, daemonize = false;      char * file = 0, * output = 0, * exec = 0;      Lua * L = 0; -#ifdef HAS_FULL_MULTITHREADING      String hport = "1500", tport = "1550", mport = "2500"; +#ifdef HAS_FULL_MULTITHREADING      pthread_t interactive_thread;  #endif @@ -910,41 +890,25 @@ virtual int startup() throw (GeneralException) {              printer = new lua_interface_printer_t(new Output(optarg));              break;          case 's': -#ifdef HAS_FULL_MULTITHREADING      	    hserver = true;      	    todo = true;              if (optarg)                  hport = optarg;      	    break; -#else -            throw GeneralException("This version doesn't support full multithreading yet."); -#endif    	          case 'm': -#ifdef HAS_FULL_MULTITHREADING      	    mserver = true;      	    todo = true;              if (optarg)                  mport = optarg; -#else -            throw GeneralException("This version doesn't support full multithreading yet."); -#endif      	    break;      	case 't': -#ifdef HAS_FULL_MULTITHREADING              tserver = true;              todo = true;              if (optarg)      	        tport = optarg;      	    break; -#else -            throw GeneralException("This version doesn't support full multithreading yet."); -#endif      	case 'f': -#ifdef HAS_FULL_MULTITHREADING      	    server_fname = optarg; -#else -            throw GeneralException("This version doesn't support full multithreading yet."); -#endif      	    break;  #ifdef HAVE_FORK  	case 'z': @@ -1053,32 +1017,29 @@ virtual int startup() throw (GeneralException) {  #endif      } -#ifdef HAS_FULL_MULTITHREADING      if (mserver || hserver || tserver) {  	TaskMan::Init();          if (hserver)  	    L->load(&Input(server_fname));      } -#endif      if (interactive) {          interactive_prompt_data_t * ipd = (interactive_prompt_data_t *) malloc(sizeof(interactive_prompt_data_t)); -#ifdef HAS_FULL_MULTITHREADING          if (mserver || tserver || hserver) { +#ifdef HAS_FULL_MULTITHREADING              ipd->w = (new PrompterTask(L))->GetWriter();              ipd->L = NULL;      	    pthread_create(&interactive_thread, NULL, interactive_prompt, ipd); -        } else {  #else -        { +            throw GeneralException("Can't start background servers while being interactive.");  #endif +        } else {              ipd->L = L;              ipd->w = NULL;              interactive_prompt(ipd);          }      } -#ifdef HAS_FULL_MULTITHREADING      if (hserver) {  	HttpServ * httpserv = new HttpServ(new Message("Welcome", "Welcome.", "start"), hport.to_int(), "Lua Interface");  	new Form("LUACall", "luacallform", "Enter the function name to call", LUACall_Names, LUACall_Invites, LUACall_Defaults, LUACall_Lists, LUACall_Descs, 1, new LUACall(L)); @@ -1095,10 +1056,11 @@ virtual int startup() throw (GeneralException) {      if (mserver || hserver || tserver) {          StartTaskLoop(0); +#ifdef HAS_FULL_MULTITHREADING          if (interactive)      	    pthread_join(interactive_thread, NULL); -    }  #endif +    }      return 0;  } | 
