I am writing a server that uses long TCP connections (a mixture of plain TCP connections and TLS ones). Occasionally I would need to update the server software, so I replace the program’s executable file, save all the internel state that I need, and call syscall.Exec
.
I would want the newly exec’ed server process to hold on to the previous process’s TCP and TLS connections.
-
Naturally what comes to mind for the TCP part, is to save the file descriptors and re-create them, via something like
IPConn.SyscallConn
to get a raw connection and to useRawConn.Control
to fiddle with the file descriptor. However, RawConn.Control says “The file descriptor fd is guaranteed to remain valid while f executes but not after f returns.” How do I ensure that the file descriptor is still going to be valid? -
How could this be done for TLS? How would I store the ephemeral state?
3