Menu

#2 Fix signal handler

closed-fixed
None
2
2008-04-17
2007-03-13
No

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".

Discussion

1 2 > >> (Page 1 of 2)
  • Markus Elfring

    Markus Elfring - 2007-03-13

    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

     
  • Centurion

    Centurion - 2007-03-13
    • status: open --> open-accepted
     
  • Centurion

    Centurion - 2007-03-13

    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.

     
  • Markus Elfring

    Markus Elfring - 2007-03-13

    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?

     
  • Centurion

    Centurion - 2007-03-15

    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...

     
  • Centurion

    Centurion - 2007-03-26

    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

     
  • Centurion

    Centurion - 2007-03-26
    • status: open-accepted --> closed-accepted
     
  • Markus Elfring

    Markus Elfring - 2007-03-26
    • status: closed-accepted --> open-accepted
     
  • Centurion

    Centurion - 2007-05-17
    • assigned_to: nobody --> darkbot
    • status: open-accepted --> closed-fixed
     
  • Centurion

    Centurion - 2007-05-17

    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

     
  • Markus Elfring

    Markus Elfring - 2007-05-17
    • status: closed-fixed --> open-later
     
  • Markus Elfring

    Markus Elfring - 2007-05-19

    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".

     
  • Centurion

    Centurion - 2007-06-22
    • status: open-later --> closed-later
     
  • Centurion

    Centurion - 2007-06-22

    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

     
  • Markus Elfring

    Markus Elfring - 2007-06-23

    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?

     
  • Markus Elfring

    Markus Elfring - 2007-06-23
    • status: closed-later --> open-later
     
  • Centurion

    Centurion - 2007-06-23

    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

     
  • Centurion

    Centurion - 2007-06-23
    • priority: 5 --> 2
    • status: open-later --> closed-wont-fix
     
  • Markus Elfring

    Markus Elfring - 2007-06-24
    • status: closed-wont-fix --> open-wont-fix
     
  • Markus Elfring

    Markus Elfring - 2007-06-24

    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.

     
  • Centurion

    Centurion - 2007-06-24
    • status: open-wont-fix --> closed-wont-fix
     
  • Markus Elfring

    Markus Elfring - 2008-04-17
    • status: closed-wont-fix --> open-fixed
     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

MongoDB Logo MongoDB