eclipse-archived / californium.core

Californium project
86 stars 69 forks source link

californium-proxy: Move doReceiveMessage(coapRequest) to its own Thread. #46

Closed mgoessen closed 8 years ago

mgoessen commented 8 years ago

This patch aims at addressing a bug in HttpStack: doReceiveMessage(coapRequest) may be blocked waiting for a response infinitely. If too much requests leading to to such behaviour are received, all HTTP Stack I/O Threads with be stuck waiting for content leading to refused requests.

This patch move the blocking call to doReceiveMessage(coapRequest) from the HTTP I/O threads to a dedicaced thread. This one is launched in http request handler (I/O thread), implementing the missing "producer" thread of the producer/consummer patern. If no response is received at time (GATEWAY_TIMEOUT), the two threads will be killed (one immediately, one after issuing a default http response).

Maybe this patch will requires additional work for a better / proper integration within the HTTP Stack. Meanwhile, it provide a working solution for a know bug [1]. We are already using it in production.

[1] https://dev.eclipse.org/mhonarc/lists/cf-dev/msg00145.html

Signed-off-by: Mathieu Goessens mathieu.goessens@telecom-bretagne.eu

mgoessen commented 8 years ago

This pull request also propose a few small cosmetic changes (remove some unnecessary exception handling ; add a more detailed one for internal exceptions within HttpStack)