]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: try to create fcgi socket through open() first
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 4 Jun 2012 23:01:07 +0000 (16:01 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Mon, 4 Jun 2012 23:12:47 +0000 (16:12 -0700)
FCGX_OpenSocket might just exit() without any warning if it fails
to create the socket.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_main.cc

index c742c1ebd3166924261d56538bc9294f452b146b..7738d4c4f536b54dad5a4ed9e4ee6b469ba1ba89 100644 (file)
@@ -193,6 +193,16 @@ void RGWProcess::run()
   int s = 0;
   if (!g_conf->rgw_socket_path.empty()) {
     string path_str = g_conf->rgw_socket_path;
+
+    /* this is necessary, as FCGX_OpenSocket might not return an error, but rather ungracefully exit */
+    int fd = open(path_str.c_str(), O_CREAT, 0644);
+    if (fd < 0) {
+      int err = errno;
+      dout(0) << "ERROR: cannot create socket: path=" << path_str << " error=" << cpp_strerror(err) << dendl;
+      return;
+    }
+    close(fd);
+
     const char *path = path_str.c_str();
     s = FCGX_OpenSocket(path, SOCKET_BACKLOG);
     if (s < 0) {