Преглед изворни кода

Found the real cause of segfaults, it was the order in which delayed hooks was been called, it should call in last in first out order, before it was first in first out.

mingodad пре 13 година
родитељ
комит
d95b4136d8
2 измењених фајлова са 4 додато и 10 уклоњено
  1. 3 9
      ext/sq_axtls.c
  2. 1 1
      squirrel/sqstate.cpp

+ 3 - 9
ext/sq_axtls.c

@@ -27,13 +27,8 @@ static const SQChar SSL_Tag[]   = _SC("sq_axtls_ssl");
 
 static SQInteger ssl_release_hook(SQUserPointer p, SQInteger size, HSQUIRRELVM v)
 {
-    /*
-    axtls mantains a list of ssl connections on ssl_ctx
-    on case of program abort it frees there all ssl connections
-    and if we try to do it here we get segault
-    */
-    //SSL *self = (SSL*)p;
-    //if(self) ssl_free(self);
+    SSL *self = (SSL*)p;
+    if(self) ssl_free(self);
 	return 0;
 }
 
@@ -42,7 +37,6 @@ static SQInteger sq_ssl_free(HSQUIRRELVM v)
     SQ_FUNC_VARS_NO_TOP(v);
     GET_ssl_INSTANCE();
     ssl_release_hook(self, 0, v);
-    ssl_free(self);
     sq_setinstanceup(v, 1, 0);
 	return 0;
 }
@@ -243,7 +237,7 @@ static int sq_axtls_get_error(HSQUIRRELVM v){
 }
 
 static SQInteger ssl_ctx_release_hook(SQUserPointer p, SQInteger size, HSQUIRRELVM v)
-{
+{
     SSL_CTX *self = (SSL_CTX*)p;
     if(self) ssl_ctx_free(self);
 	return 0;

+ 1 - 1
squirrel/sqstate.cpp

@@ -247,7 +247,7 @@ void SQSharedState::CallDelayedReleaseHooks(SQVM *vm, int count)
         //calling each release hook new ones can be added
         //to the list, the new ones will be processed on next call
         if(count == 0) count =  _delayed_release_hook.size();
-        for(SQInteger i=0; i < count; ++i){
+        for(SQInteger i=count-1; i >= 0; --i){
             SQDelayedReleseHook &dh = _delayed_release_hook[i];
             dh.hook(dh.ptr, dh.size, vm);
         }