~schuster/mysql-proxy/remove_unix_socket

« back to all changes in this revision

Viewing changes to src/network-address.c

  • Committer: michael.schuster at oracle
  • Date: 2010-04-29 13:23:08 UTC
  • Revision ID: michael.schuster@oracle.com-20100429132308-mqtz5rkrt031un13
remove unix socket at shutdown: remove race window, make logic for "remove the once we created only" better

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
         * if the name we're freeing starts with a '/', we're
74
74
         * looking at a unix socket which needs to be removed
75
75
         */
76
 
        if (addr->fail_errno == 0 && addr->name != NULL &&
 
76
        if (addr->can_unlink_socket == TRUE && addr->name != NULL &&
77
77
                        addr->name->str != NULL) {
78
78
                gchar   *name;
79
79
                int             ret;
80
80
 
81
81
                name = addr->name->str;
82
 
                if (name[0] == '/' && g_access(name, 0) == 0) {
 
82
                if (name[0] == '/') {
83
83
                        ret = g_remove(name);
84
 
                        if (ret == 0) 
 
84
                        if (ret == 0) {
85
85
                                g_debug("%s removing socket %s successful", 
86
86
                                        G_STRLOC, name);
87
 
                        else
88
 
                                g_critical("%s removing socket %s failed: %s (%d)", 
89
 
                                        G_STRLOC, name, strerror(errno));
 
87
                        } else {
 
88
                                if (errno != EPERM && errno != EACCES)
 
89
                                        g_critical("%s removing socket %s failed: %s (%d)", 
 
90
                                                G_STRLOC, name, strerror(errno));
 
91
                        }
90
92
                }
91
93
        }
92
94
#endif /* WIN32 */