Hello everyone i’m developing OpenGL visualization application under Linux that can get data by UDP. I’ve create the new thread by SDL_CreateThread func, then i’ve the socket in this thread and sending the data via UDP from python script with frequency 25 Hz. Sometimes it causes freezing main thread or everytime some mainthread slowdown. How can i solve this problem? There is code of socket part:
I’m not sure why you think that this is a SDL issue. When you have general
programming problems, there are general purpose sites, forums or mailing
lists you can use.
In the spirit of helping, I see the following potential problems:
recvfrom() is a blocking call. You are using select(), but not testing
the values to see if it is safe to read from the socket without blocking.
There is a security problem in your code. What do you think would
happen if I sent you a packed 2048 bytes long, with no NUL terminator?
I’m assuming your main thread reads from “qu” and this auxiliary thread
writes to it, If so, unless you are protecting “qu”, the behaviour of your
program is undefined.
You drop packets when the queue is full, without any logging. Someone
could trivially DOS your server by sending many tiny packets, keeping the
queue full of spam.
You are quite light on error checking too. Errors can sometimes
compound one another, so you should have robust error detection, handling
and logging to ensure that a simple early error doesn’t cascade.
Regards,
– Brian.On 29 September 2011 06:03, qmor <qmor.qmor at gmail.com> wrote:
**
Hello everyone i’m developing OpenGL visualization application under Linux
that can get data by UDP. I’ve create the new thread by SDL_CreateThread
func, then i’ve the socket in this thread and sending the data via UDP from
python script with frequency 25 Hz. Sometimes it causes freezing main thread
or everytime some mainthread slowdown. How can i solve this problem? There
is code of socket part: