GNU libmicrohttpd 0.9.77
Loading...
Searching...
No Matches
mhd_itc.c
Go to the documentation of this file.
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2016 Karlson2k (Evgeny Grin)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19*/
20
28#include "mhd_itc.h"
29#ifdef HAVE_UNISTD_H
30#include <unistd.h>
31#endif /* HAVE_UNISTD_H */
32#include <fcntl.h>
33#include "internal.h"
34
35
36#if defined(_MHD_ITC_PIPE)
37#if ! defined(_WIN32) || defined(__CYGWIN__)
38
39#ifndef HAVE_PIPE2_FUNC
46int
47MHD_itc_nonblocking_ (struct MHD_itc_ itc)
48{
49 unsigned int i;
50
51 for (i = 0; i<2; i++)
52 {
53 int flags;
54
55 flags = fcntl (itc.fd[i],
56 F_GETFL);
57 if (-1 == flags)
58 return 0;
59
60 if ( ((flags | O_NONBLOCK) != flags) &&
61 (0 != fcntl (itc.fd[i],
62 F_SETFL,
63 flags | O_NONBLOCK)) )
64 return 0;
65 }
66 return ! 0;
67}
68
69
70#endif /* ! HAVE_PIPE2_FUNC */
71#endif /* !_WIN32 || __CYGWIN__ */
72#endif /* _MHD_ITC_EVENTFD || _MHD_ITC_PIPE */
MHD internal shared structures.
Header for platform-independent inter-thread communication.