NetworkBlockDevice / nbd

Network Block Device
GNU General Public License v2.0
450 stars 116 forks source link

Use the real genconf.threads, not an uninitialized value #97

Closed juhaerk closed 5 years ago

juhaerk commented 5 years ago

When HUP-signal is sent to nbd-server, append_new_servers() function is executed and it looks up new "max_threads" value from configuration. Unfortunately, when such a value is not provided by configuration, it uses an uninitialized memory value for it. Most often this is a big number such as 32612, and no serious issues arise. However, sometimes this might be zero, depending on memory usage patterns, thus leading to max threads value of 0 provided to g_thread_pool_set_max_threads(), meaning that all nbd data sends are stopped. In this situation all new clients negotiate with server just fine, but they receive no data.

In this fix the real configuration data is used, or the default of four threads if configuration does not provide a value.

(The issue can be worked around by setting "max_threads 4" or some other sensible value in /etc/nbd-server/config "[generic]"-section.)