Procházet zdrojové kódy

Some fixes to work without axtls/ssl

mingodad před 12 roky
rodič
revize
9e2f52907b
2 změnil soubory, kde provedl 10 přidání a 6 odebrání
  1. 8 4
      SquiLu-ext/mongoose.c
  2. 2 2
      SquiLu-ext/sq_mongoose.cpp

+ 8 - 4
SquiLu-ext/mongoose.c

@@ -764,10 +764,12 @@ static const char *ssl_error(int err_code) {
             break;
     }
     return ssl_get_error(err_code, buf, sizeof(buf));
-#else
+#elif !defined(NO_SSL)
   unsigned long err;
   err = ERR_get_error();
-  return err == 0 ? "" : ERR_error_string(err, NULL);
+  return err == 0 ? "" : ERR_error_string(err, NULL);
+#else
+  return "";
 #endif
 }
 
@@ -4542,7 +4544,7 @@ static int load_dll(struct mg_context *ctx, const char *dll_name,
 // Dynamically load SSL library. Set up ctx->ssl_ctx pointer.
 static int set_ssl_option(struct mg_context *ctx) {
   struct mg_request_info request_info;
-  SSL_CTX *CTX;
+  SSL_CTX *CTX = 0;
   int i, size;
   int ssl_result;
   const char *pem = ctx->config[SSL_CERTIFICATE];
@@ -4640,7 +4642,9 @@ static void uninitialize_ssl(struct mg_context *ctx) {
   if (ctx->ssl_ctx != NULL) {
     CRYPTO_set_locking_callback(NULL);
     for (i = 0; i < CRYPTO_num_locks(); i++) {
-      pthread_mutex_destroy(&ssl_mutexes[i]);
+      if(ssl_mutexes[i]) {
+          pthread_mutex_destroy(&ssl_mutexes[i]);
+      }
     }
     CRYPTO_set_locking_callback(NULL);
     CRYPTO_set_id_callback(NULL);

+ 2 - 2
SquiLu-ext/sq_mongoose.cpp

@@ -151,7 +151,7 @@ sq_http_request_read(HSQUIRRELVM v)
     if(n <= 0) return sq_throwerror(v, _SC("invalid size to read (%d)"), n);
     size_t rlen;  /* how much to read */
     size_t nr;  /* number of chars actually read */
-    rlen = 8192;  /* try to read that much each time */
+    rlen = 8192*2;  /* try to read that much each time */
 
     SQBlob blob(0, rlen);
     if (rlen > n) rlen = n;  /* cannot read more than asked */
@@ -1240,8 +1240,8 @@ user_callback_proxy(enum mg_event event,
 #ifdef USE_AXTLS
             //lua_pushstring(L, "MG_INIT_SSL");
             *((void**)conn) = SSL_CTX_new(0);
-            return 0;
 #endif
+            return 0;
         case MG_NEW_REQUEST:
         case MG_HTTP_ERROR:
         case MG_EVENT_LOG:{