* Send a socket to a thread This is called from the dispatch UST registration
* thread once all sockets are set for the application.
*
+ * The sock value can be invalid, we don't really care, the thread will handle
+ * it and make the necessary cleanup if so.
+ *
* On success, return 0 else a negative value being the errno message of the
* write().
*/
{
int ret;
- /* Sockets MUST be set or else this should not have been called. */
- assert(fd >= 0);
- assert(sock >= 0);
+ /*
+ * It's possible that the FD is set as invalid with -1 concurrently just
+ * before calling this function being a shutdown state of the thread.
+ */
+ if (fd < 0) {
+ ret = -EBADF;
+ goto error;
+ }
do {
ret = write(fd, &sock, sizeof(sock));
if (ret < 0) {
rcu_read_unlock();
session_unlock_list();
- /* No notify thread, stop the UST tracing. */
+ /*
+ * No notify thread, stop the UST tracing. However, this is
+ * not an internal error of the this thread thus setting
+ * the health error code to a normal exit.
+ */
+ err = 0;
goto error;
}
if (ret < 0) {
rcu_read_unlock();
session_unlock_list();
- /* No apps. thread, stop the UST tracing. */
+ /*
+ * No apps. thread, stop the UST tracing. However, this is
+ * not an internal error of the this thread thus setting
+ * the health error code to a normal exit.
+ */
+ err = 0;
goto error;
}