The important thing is to cleanly save the contexts (core and GUI settings) to be able to restart without losing too much information.
The NAT-PMP unpublish operation tries to resend its operation when it gets an URPC_TIMEOUT indication. Therefore, to cleanly abort the operation at shutdown time, we need a distinct URPC_ABORT indication. Ottherwise, we could get assertion failures in the URPC layer when exiting.
…ted memory. When this happens, we start using NULL memory hints and we do not want any stacktrace and warnings telling us about the fact we did not allocate memory with a hinted address!
…m the end.
As written, the check was fast and wrong... A lock can be marked as having a writer without us being the locking thread, as long as the writing thread is waiting for the last read lock to be gone... We need a formal check if we are to assert that we have taken the lock.
…ng OOM. On Windows, when we have exhausted the initially reserved VM space, we attempt to allocate outside the reserved region. If we succeed, we also request a clean application restart because we are close to an out-of-memory condition.
The new page_cache_free_all() routine will now remove all the cached pages. It can also be used at shutdown time, which means we can get rid of vpc_free().
…tegy. Also suppressed pmap_is_within_region() since it is the exact negation of pmap_is_extremity(), introduced at last commit.
This is not a POSIX error code, but it is used by Windows and could also appear with some UNIX kernels like BSD and Linux.
…ate memory. To be thread-safe, compact_size() uses str_private() and therefore can allocate memory, possibly causing recursion into mingw_valloc() to get more memory, which would then call compact_size() again!
…= 0". When the argument is socket_fd_t, the "fd >= 0" expression triggers a warning on Windows because it is an unsigned quantity there.
…ready used. Before forcing SO_REUSEADDR on the socket, we want to check whether the port is already used, to be able to warn them about that. This would have made the diagnosis of the Windows bug (lack of close-on-exec leading to undefined behaviour upon auto-restart) much easier!
…c(). There is no support for close-on-exec on Windows, and file descriptors do no share the same ID space as sockets. Therefore, we need to remember all the socket descriptors in order to let close_file_descriptors() also handle sockets before exec() is run. This will fix a nasty problem on Windows whereby an auto-restart left the listening socket active. There were thus two listening sockets on the same TCP port, once gtk-gnutella had re-exec'ed itself, preventing any further incomoing TCP connections from being handled properly.
…counts. When changing the listening port dynamically, exsting UPnP mappings are revoked and new ones installed if needed. However, we were freeing the old mapping objects whilst the UPnP RPC was in transit, resulting in a crash when the reply came back since the mapping object given as argument was gone.
We want to avoid any recursion on the exit path, should crash_restart() end up being called when we have already started shutting the application down.