cmogstored.git  about / heads / tags
alternative mogstored implementation for MogileFS
blob c840da3e6d93d002adecda856d3def33f6356778 813 bytes (raw)
$ git show HEAD:close.c	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
/*
 * Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 */
#include "cmogstored.h"
void mog_close(int fd)
{
	if (close(fd) == 0)
		return;

	switch (errno) {
	case ECONNRESET:
		/*
		 * FreeBSD (and other BSDs) may return ECONNRESET on close(),
		 * but the file descriptor _does_ seem to be released.
		 * Retrying close() will break since we create descriptors
		 * in different threads
		 */
	case EINTR: return; /* nothing we can do */
	case EBADF:
		/* EBADF would be a disaster since we use threads */
		syslog(LOG_CRIT, "BUG: attempted to close(fd=%d)", fd);
		assert(0 && fd && "won't attempt to continue on bad close()");
	default: /* EIO, nothing we can do... */
		syslog(LOG_ERR, "close(fd=%d) failed: %m", fd);
	}
}

git clone https://yhbt.net/cmogstored.git