I am posting this since I am not able to debug it anymore. I read everything multiple times, but still I have no reliable solution. We added a 30 seconds timeout to reset the board anytime it hangs in the event_handler waiitng for a response, but this is to the point I get more reset per day than succesful connections.
So, on ourboard the cc3000 hangs often in the following points:
recv: this is almost solved. Now I close and reopen the connecton multiple times (almost anytime before sending and expecting a response. TO NOTE: here no timeout set and no select() function helped. It was still hanging in the eventhandler very often. With the select in place, often the SELECT function would hang.
connect(): this is the most frequent one. No way to make it timing out. I tried re-setting the timeout to 20 seconds, but nothing, the handler timeout gets called first.
gethostbyname: this was very frequent and I think alternates with the connect problem one. It got better waiting for the DHCP part to the completed on connection (at least I think), but it still happens. I even implement 2 retries, and they helped a lot(since ususally the first time fails, but the second one works)..but still..from time to time, it hangs there. I don't think there is anything I can do here.
Now I am at the point that I disconnect, reset the module, reconnect only when I really need to send some data through wifi. Is the anything else I can try? I am using the latest patch programmer, of course.
We are thinking about desoldering and return our 1000 cc3000 to TI if we don't find a solution.