threadlocal: Copy thread name
We can't guarantee what storage duration the caller's request
for a thread name has; and in fact, if the caller uses
plugin_name() for their thread name, then the moment .unload
is called, our threadlocal storage is pointing to la-la-land
and we get a nice SEGV while trying to print any debug message.
So copy the user's string instead.
Make the update best-effort, since we may be creating a new
thread while an existing connection is already in service. If
strdup fails, we'll mention the failure, but it's better to
still keep the program running with no thread name than to
die [of course, if strdup fails, we'll probably face other
failures quite soon].
Signed-off-by: Eric Blake <eblake@redhat.com>