sem_setup should use SEM_UNDO flag
|Reported by:||Darac||Owned by:||nobody|
The sem_setup function (in munin-cgi-graph and munin-fastcgi-graph) should use the SEM_UNDO flag in the call to semop to avoid overflowing the semaphore value.
man 2 semop states that the behaviour of semop() with a positive sem_op is to increment the semaphore value by this amount. The sem_*() functions use the value in the semaphore as a 'number of available jobs', decrementing the count before calling munin-graph and incrementing it afterwards. If sem_setup is called several times (as would happen with munin-cgi-graph), then the semaphore value is incremented by $max_cgi_graph_jobs each time. If the semaphore value would exceed SEMVMX, an error is returned and perl dies.
If we add SEM_UNDO, though, the amount we added to the semaphore in sem_setup is automatically removed when the process finishes.
The attached patch fixes this for 1.4.2
Change History (4)
Changed 3 years ago by Darac
comment:2 Changed 3 years ago by janl
- Component changed from web-interface to master
- Milestone Munin 1.5 deleted
- Resolution fixed deleted
- Status changed from closed to reopened