Retry failed rebind attempts

When we receive a migration, if rebinding to the new listen address and
port fails for a reason which might be fixable, rather than killing the
server we retry once a second.  Also in this patch: non-overlapping log
messages and a fix for the client going away halfway through a sendfile
loop.
This commit is contained in:
Alex Young
2012-07-12 14:14:46 +01:00
parent 9002341e77
commit 10b46beeea
12 changed files with 194 additions and 20 deletions

View File

@@ -44,13 +44,24 @@ void exit_err( const char *msg )
void mylog(int line_level, const char* format, ...)
{
va_list argptr;
if (line_level < log_level) { return; }
/* Copy the format sideways so that we can append a "\n" to it
* and avoid a second fprintf. This stops log lines from getting
* interleaved.
*/
int format_len = strlen( format );
char *format_n = xmalloc( format_len + 2 );
memcpy( format_n, format, format_len );
format_n[format_len] = '\n';
va_start(argptr, format);
vfprintf(stderr, format, argptr);
vfprintf(stderr, format_n, argptr);
va_end(argptr);
fprintf(stderr, "\n");
free( format_n );
}
void* xrealloc(void* ptr, size_t size)