lib:ldb: Use correct integer types for sizes
[vlendec/samba-autobuild/.git] / source3 / lib / tallocmsg.c
index af5a90bb434bdae78a526b17a5df37e1d3fef0b6..a5c6603a92b7702968874071c9b9c794d5fb4acd 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
-#include "messages.h"
+#include "replace.h"
+#include "source3/include/messages.h"
+#include "source3/lib/tallocmsg.h"
 #include "lib/util/talloc_report_printf.h"
+#include "lib/util/debug.h"
+#include "lib/util/util_file.h"
 
 static bool pool_usage_filter(struct messaging_rec *rec, void *private_data)
 {
        FILE *f = NULL;
-       int fd;
 
        if (rec->msg_type != MSG_REQ_POOL_USAGE) {
                return false;
@@ -36,18 +38,9 @@ static bool pool_usage_filter(struct messaging_rec *rec, void *private_data)
                return false;
        }
 
-       fd = dup(rec->fds[0]);
-       if (fd == -1) {
-               DBG_DEBUG("dup(%"PRIi64") failed: %s\n",
-                         rec->fds[0],
-                         strerror(errno));
-               return false;
-       }
-
-       f = fdopen(fd, "w");
+       f = fdopen_keepfd(rec->fds[0], "w");
        if (f == NULL) {
                DBG_DEBUG("fdopen failed: %s\n", strerror(errno));
-               close(fd);
                return false;
        }