-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are concurrent operations supported between server and client #507
Comments
It is not clear from the information provided so far as to what you are trying to do and hence the issues you are seeing. You refer to 'context' being put in session->add. Is this a coap_context_t or some other context? Have you tried running the client under the control of valgrind ? It is unclear how you are trying to do the concurrent operations. What version of libcoap are you using ? |
Version: I had taken code from "develop" branch about 3-4 months back(approx.), right after the "mbedtls" support came in. How I am doing concurrent operations:I have TWO threads. 2. Poll thread: **This is now I have made the libcoap in/out single threaded. Issue I am facing:At the time of sending, I am setting a application context in context->app. This is not the coap context. The memory is allocated at heap and freed after receiving a response. So, till the client receives the response before send next request, it works fine. But when server delays a response (infact for several requests), client starts showing issues. Somtimes my message_handler gets invoked twice for a single session(resulting in double free error in my handler) and somtimes I find the APP context corrupted. My question is:
Please let me know if I need to provide more information. |
Your approach could indeed work. As you already have found, you need to take special care when setting context->app as it is like global data in your main thread. So, when different request/response pairs overlap and you delete or change the data in one response handler this will affect everything that happens afterwards. Regarding the delay: Not surprisingly, the code is written not to introduce additional delays. But as the response is created in your resource handler you could easily introduce a delay there (which of course, affects the timing in your entire main thread). |
Do you mean context->app or session->app ? I would expect session->app. Where do you free off the created coap_session_t used for each coap_send()? Are you using a unique Token per coap_send() https://tools.ietf.org/html/rfc7252#section-5.3 and https://tools.ietf.org/html/rfc7252#section-5.3.1 ? |
Did we come to any conclusion on this? |
I have implemented CoAP client and server using this library. Both are working nice till server responds to each requests immediately and after server response next requests starts. However I am facing some issues at the client end when some requests are responded lately by server.
Regarding issues that I have observed:
I have set a context in the session->app member. In the above mentioned troubled scenarios, I am observing memory corruption there at the client side. Server is running fine without any issues.
Any suggestion is appreciated.
The text was updated successfully, but these errors were encountered: