diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-13 15:00:33 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-13 15:00:33 +0000 |
commit | 3ec976177fd1a437f0a1a2411eef3620f619c8e3 (patch) | |
tree | c34aa4a03c3c8cf8c354d35f8a90dc8a41b6d239 /src/util/network.c | |
parent | 95ca464081406ce98e17f08d180a550a647a2720 (diff) | |
download | gnunet-3ec976177fd1a437f0a1a2411eef3620f619c8e3.tar.gz gnunet-3ec976177fd1a437f0a1a2411eef3620f619c8e3.zip |
-fix #3211
Diffstat (limited to 'src/util/network.c')
-rw-r--r-- | src/util/network.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/util/network.c b/src/util/network.c index d3a891a63..00f6ebf3b 100644 --- a/src/util/network.c +++ b/src/util/network.c | |||
@@ -476,11 +476,41 @@ GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc) | |||
476 | if ((desc->af == AF_UNIX) && (NULL != desc->addr)) | 476 | if ((desc->af == AF_UNIX) && (NULL != desc->addr)) |
477 | { | 477 | { |
478 | const struct sockaddr_un *un = (const struct sockaddr_un *) desc->addr; | 478 | const struct sockaddr_un *un = (const struct sockaddr_un *) desc->addr; |
479 | char *dirname = GNUNET_strndup (un->sun_path, | ||
480 | sizeof (un->sun_path)); | ||
479 | 481 | ||
480 | if (0 != unlink (un->sun_path)) | 482 | if (0 != unlink (dirname)) |
483 | { | ||
481 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, | 484 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, |
482 | "unlink", | 485 | "unlink", |
483 | un->sun_path); | 486 | dirname); |
487 | } | ||
488 | else | ||
489 | { | ||
490 | size_t len; | ||
491 | |||
492 | len = strlen (dirname); | ||
493 | while ((len > 0) && (dirname[len] != DIR_SEPARATOR)) | ||
494 | len--; | ||
495 | dirname[len] = '\0'; | ||
496 | if (0 != rmdir (dirname)) | ||
497 | { | ||
498 | switch (errno) | ||
499 | { | ||
500 | case EACCES: | ||
501 | case ENOTEMPTY: | ||
502 | case EPERM: | ||
503 | /* these are normal and can just be ignored */ | ||
504 | break; | ||
505 | default: | ||
506 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
507 | "rmdir", | ||
508 | dirname); | ||
509 | break; | ||
510 | } | ||
511 | } | ||
512 | } | ||
513 | GNUNET_free (dirname); | ||
484 | } | 514 | } |
485 | #endif | 515 | #endif |
486 | GNUNET_NETWORK_socket_free_memory_only_ (desc); | 516 | GNUNET_NETWORK_socket_free_memory_only_ (desc); |