r84760 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84759‎ | r84760 | r84761 >
Date:20:32, 25 March 2011
Author:platonides
Status:ok
Tags:
Comment:
Make a graceful restart use the filesystem binary instead of the in-memory copy.
This way it also works for upgrading the code without interrupting the service.
Modified paths:
  • /trunk/extensions/PoolCounter/daemon/main.c (modified) (history)

Diff [purge]

Index: trunk/extensions/PoolCounter/daemon/main.c
@@ -17,11 +17,17 @@
1818 static int open_sockets = 1; /* Program will automatically close when this reaches 0 */
1919
2020 static struct event listener_ev;
 21+static char** global_argv;
 22+
2123 int main(int argc, char** argv) {
2224 struct event_base *base;
2325 struct stat st;
2426 int listener;
2527
 28+ if ( argc >= 1 ) {
 29+ global_argv = argv;
 30+ }
 31+
2632 if ( fstat( 0, &st ) || ! S_ISSOCK( st.st_mode ) ) {
2733 close( 0 ); /* Place the listener socket in fd 0 */
2834 listener = listensocket( PORT );
@@ -177,7 +183,11 @@
178184 end( 0 );
179185 }
180186 } else {
181 - execl( "/proc/self/exe", "poolcounterd", NULL );
 187+ if ( global_argv ) {
 188+ execvp( global_argv[0], global_argv );
 189+ } else {
 190+ execl( "/proc/self/exe", "poolcounterd", NULL );
 191+ }
182192 exit( 1 );
183193 }
184194 }

Status & tagging log