I am building a client/server protocol using libwebsockets library. In the poll thread, each callback on incoming packets triggers a certain method to either save data, respond accordingly, and so on. However, if there are other incoming packets that would trigger LWS_CALLBACK_CLIENT_RECEIVE, the processing of the previous task is left undone.
Is there a way to finish the tasks before dealing with the packets received? Should LWS_CALLBACK_CLIENT_RECEIVE start new threads to handle the processing of data?