x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

FRunnable thread freezes editor.

Hi,

I'm creating a FRunnable on UGameInstance.Init() with FRunnableThread::Create

In Run() function I'm reading from a socket with recv and the thread gets locked waiting for data. If I stop the editor it freezes waiting for thread to finalize. I override Shutdown() and BeginDestroy() in UGameInstance closing the socket with closesocket but this functions are never called.

Anybody knows why this functions are never called and how can I solve it? Thank you in advance.

Product Version: UE 4.12
Tags:
more ▼

asked Jul 26 '16 at 10:27 AM in C++ Programming

avatar image

intrus03
1 1 2

avatar image Truun Jul 26 '16 at 11:26 AM

Could you show some code of your run function so that I know what youre doing? It's possible that run is never finished and the main thread will freeze trying to destroy the thread when waiting for it to finish first.

avatar image intrus03 Jul 26 '16 at 11:46 AM

Sure... As I said recv func locks the thread. If the main thread tries to destroy it I don't understand how the cleanup works because Stop() is never called.

 uint32 SocketManager::Run()
 {
     while (true)
     {
         int32 iResult = recv(wsSocket, recvbuf, BUFLEN, 0);
         if (iResult <= 0)
         {
             break;
         }
     }
 
     return 0;
 }
 
 void SocketManager::Stop()
 {
     if (wsSocket != INVALID_SOCKET)
     {
         closesocket(wsSocket);
         wsSocket = INVALID_SOCKET;
     }
 }
avatar image intrus03 Jul 27 '16 at 07:20 AM

Can anybody help me? If anyone knows any other way to do it I would be very grateful that inicase me how. Thank you.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Resolved. Thanks.

more ▼

answered Jul 27 '16 at 08:54 AM

avatar image

intrus03
1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question