Fix signal handler
Brought to you by:
darkbot
The functions "snprintf()" and "sscanf()" do not belong to the list of async-signal-safe functions.
See section "2.4.3 Signal Actions" from the document "2.4 Signal Concepts".
http://opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03
I guess that a different program design will be needed for your function "alarm_signal".
Logged In: YES
user_id=572001
Originator: YES
The data type of the variable "quit" should also be changed from "BYTE" to "sig_atomic_t".
Would alternative design approaches be needed for complete thread safety?
http://opengroup.org/onlinepubs/009695399/functions/sem_post.html
Logged In: YES
user_id=1289228
Originator: NO
Seems like "different program design" means in fact rewritting program from the beginning, unfortuntely I don't have so much time and knowledge to do it by myself.
There is also a lot of snprintf() and sscanf() calls in program functions, however in
async-signal-safe functions list I can't find also sprintf/scanf so I guess, this will require changes to some similar functions, but this is out of my knowlege (damn, I'm not a good programmer ;))
Changing quit from BYTE to sig_atomic_t will be done in next version of DB Hub.
I've noticed that semaphores/shared_memory area can get broken and leads to hang ups or freezes, especially on bigger hubs.
sem_post()/sem_wait() seems to be the right way to remove the bug, however I need to read more of it.
Base of DC Hub is mostly taken from OpenDCHub so I am still learning it slowly.
Ok, thanks for your suggestion, and if you wanna help me, feel welcome.
Logged In: YES
user_id=572001
Originator: YES
Is the OpenDCHub software similarly affected?
Would you like to forward the issue to the other developers?
Are you going to reuse any (class) library for the mentioned use case?
Logged In: YES
user_id=1289228
Originator: NO
> Is the OpenDCHub software similarly affected?
ODCH is quite stable, however it's slow and eat much more resources than DB Hub
but is use the same sememaphores/shared memory stuff like in DB Hub
> Would you like to forward the issue to the other developers?
ODCH project is dead, so there are no developers, I think I am the only one and the one who strats being tired of this DB Hub unstability
>Are you going to reuse any (class) library for the mentioned use case?
I don't know if I understood you properly. I would do anything to make DB Hub stable, however I'm limited by time and... knowledge. This whole semaphores stuff is too hard for me right now.
Maybe if someone can help me...
Logged In: YES
user_id=1289228
Originator: NO
well I made DB Hub to use only one semaphore for user list and do it safe (not allow to open it if it's already in use), that should do the trick
Logged In: YES
user_id=572001
Originator: YES
It seems that your signal handling is still not async-signal-safe.
http://dbhub.cvs.sourceforge.net/dbhub/dbhub/src/main.c?revision=1.16&view=markup
Logged In: YES
user_id=1289228
Originator: NO
finally, I've changed SIGALARM and all semaphore/shared memory handlers to run through only one process (process stroing users) and now it seems that this made the soft stable
Logged In: YES
user_id=572001
Originator: YES
I see that there are still signal-unsafe functions called.
http://dbhub.cvs.sourceforge.net/dbhub/dbhub/src/main.c?revision=1.81&view=markup
Logged In: YES
user_id=572001
Originator: YES
The selection of functions that may be called from inside a signal handler is limited. I suggest to change the implementation of the function "alarm_signal".
Logged In: YES
user_id=1289228
Originator: NO
well despide of issue you're talking to (I have no idea how to solve it in other way) the last version of DB Hub is totally stable, it's running for over 7 weeks now and can handle 1500 users (on 100Mbit upload) at the same time without any problems (will be tested with more users soon)
however I want to thank you for you suggestions which I've found really useful for me
thanx a lot, I am closing this tracker
Logged In: YES
user_id=572001
Originator: YES
Your implementation is still insecure because it is not compliant to the POSIX standard.
http://dbhub.cvs.sourceforge.net/dbhub/dbhub/src/main.c?revision=1.82&view=markup
Do you care for such correctness?
When will the data type "sig_atomic_t" be used at the appropriate places?
Logged In: YES
user_id=1289228
Originator: NO
software works stable that all I know. I told you that I am not a good programmer and since last version nobody has reported any problems with it so I am satisfied and I won't mess with the code even if there are some details that should be corrected
well, you may correct the code by yourself if you want but I don't consider that you will do it
anyway, I have stopped developing this project since there is no any bug reports about crashed ot strange behaviour and there is nothing more to add to its funcionallity
thank you for yours hints, regards
Logged In: YES
user_id=572001
Originator: YES
I suggest to avoid programming errrors. Correct signal handling should be achieved. It is a pity that we do not get consensus on the way to this goal.
Logged In: YES
user_id=572001
Originator: YES
Thanks for the correction.
http://dbhub.cvs.sourceforge.net/dbhub/dbhub/src/main.h?r1=1.67&r2=1.68
http://dbhub.cvs.sourceforge.net/dbhub/dbhub/src/main.c?r1=1.83&r2=1.84