I have an stunnel build for iOS and it works perfectly, but when I try to restart it app crashes.
I'm starting it with pthread_create. Here is the code to restart.
int ret;
ret = pthread_cancel(old_threadID);
if (ret != 0)
NSLog(@"%i", ret);
void *res;
ret = pthread_join(old_threadID, &res);
if (ret != 0)
NSLog(@"%i", ret);
if (res == PTHREAD_CANCELED)
NSLog(@"main(): thread was canceled\n"); //This returns OK
else
NSLog(@"main(): thread wasn't canceled (shouldn't happen!)\n");
//Begin new thread
pthread_t threadID;
//launch stunnel in a thread
int errorStunnel = pthread_create(&threadID, NULL, &stunnel_routine, (void *)fname);
NSLog(@"Error code!! : %i", errorStunnel); //error is 0.
After this App crashes. It crashes because can not start properly. as I see in stunnel.log because of this: "Error binding :443 to 127.0.0.1:12345 bind: Address already in use (48)" Config file didn't change. So why ports are still binded with previous thread?