Commit Graph

149 Commits

Author SHA1 Message Date
Xiang Xiao
6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Xiang Xiao
02b652ce1c Minor fix (#23)
* fix ieee802154/ieee802154_input.c:179:7: error: too few arguments to function 'iob_free'
       iob_free(container->ic_iob);
       ^~~~~~~~

ieee802154/ieee802154_input.c:180:7: error: too many arguments to function 'ieee802154_container_free'
       ieee802154_container_free(container, IOBUSER_NET_SOCK_IEEE802154);
       ^~~~~~~~~~~~~~~~~~~~~~~~~

* fix udp/udp_netpoll.c:327:10: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]

* fix local/local_netpoll.c:154:15: warning: implicit declaration of function 'nxsem_post'; did you mean 'sem_post'? [-Wimplicit-function-declaration]
               nxsem_post(fds->sem);
               ^~~~~~~~~~
               sem_post
2020-01-02 09:35:50 -06:00
Xiang Xiao
90c52e6f8f Squashed commit of the following:
Author: Gregory Nutt <gnutt@nuttx.org>

    Run all .h and .c files modified in last PR through nxstyle.

Author: Xiang Xiao <xiaoxiang@xiaomi.com>

    Net cleanup (#17)

    * Fix the semaphore usage issue found in tcp/udp

    1. The count semaphore need disable priority inheritance
    2. Loop again if net_lockedwait return -EINTR
    3. Call nxsem_trywait to avoid the race condition
    4. Call nxsem_post instead of sem_post

    * Put the work notifier into free list to avoid the heap fragment in the long run.  Since the allocation strategy is encapsulated internally, we can even refine the implementation later.

    * Network stack shouldn't allocate memory in the poll implementation to avoid the heap fragment in the long run, other modification include:

    1. Select MM_IOB automatically since ICMP[v6] socket can't work without the read ahead buffer
    2. Remove the net lock since xxx_callback_free already do the same thing
    3. TCP/UDP poll should work even the read ahead buffer isn't enabled at all

    * Add NET_ prefix for UDP_NOTIFIER and TCP_NOTIFIER option to align with other UDP/TCP option convention

    * Remove the unused _SF_[IDLE|ACCEPT|SEND|RECV|MASK] flags since there are code to set/clear these flags, but nobody check them.
2019-12-31 09:26:14 -06:00
Gregory Nutt
3b275fcf4e net/: Run nxstyle against all C files. 2019-10-25 11:31:42 -06:00
Juha Niskanen
e8b5dd4528 Fix use of undefined pp-token #errror, other typos. 2019-09-19 18:19:18 -06:00
Gregory Nutt
d596e56c3d net/local/local_conn.c: Removed un-ncessary memset(). Connection structure is allocated with kmm_zalloc() which will clear all memory. 2019-09-01 11:23:40 -06:00
Gregory Nutt
6266e067e9 net/: Re-order the content of all address-family socket 'connection' structures so that they begin with a comomon prologue. This permits better use of logic for different address family types. 2019-09-01 08:47:01 -06:00
Gregory Nutt
1346f29151 net/: Fix alignment and spacing problems found by tools/nxstyle. 2019-07-02 18:02:23 -06:00
Juha Niskanen
abc49a6a13 arch/arm/src/stm32l4: if SRAM3 is used as heap, do not power it off in stop 2 mode. 2019-06-13 05:52:40 -06:00
Gregory Nutt
b49be4bb20 Squashed commit of the following:
arch/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    sched/ audio/ crypto/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    Documentation/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    fs/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    graphics/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    net/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    drivers/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    include/, syscall/, wireless/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    configs/:  Remove all references to CONFIG_DISABLE_POLL.  Standard POSIX poll can no longer be disabled.
2019-05-21 18:57:54 -06:00
zhangyuan7
81a3ec250e net/local: Fixed deadlock issue by replacing nxsem_wait() with net_lockedwait() so that we do not wait with the network locked. 2019-03-19 09:54:22 -06:00
zhangyuan7
656c20fd4a net/local/local_connect.c: Initialize lc_result before giving lc_waitsem 2019-03-19 09:52:40 -06:00
Gregory Nutt
f6b00e1966 tools/nxstyle.c: Fix logic error that prevent detecion of '/' and '/=' as operators. net/: Minor updates resulting from testing tools/nxstyle. 2019-03-11 12:48:39 -06:00
Gregory Nutt
a01cbede38 net/local/local_fifo.c: Fix an error found in build testing. 2018-09-15 18:13:49 -06:00
Gregory Nutt
3a4984a40b Rename file_close_detached() to juse file_close() for better consistency in naming. 2018-09-15 13:04:56 -06:00
Gregory Nutt
a7fd58c4db Squashed commit of the following:
many locations:  Change occurences of open() followed by file_detach() to file_open().  Change most non-controversion calls to open() to nx_open().

    fs/inode/fs_fileopen.c:  Flesh out file_open() with some interim, placeholder logic.

    fs/inode/fs_fileopen.c:  Add a framework for a file_open() implementation (no real logic in place yet).

    fs/vfs/fs_open.c:  Add nx_open() which is the same as open() except that it does not create a cancellation point nor does it modify the errno variable.
2018-09-15 10:49:41 -06:00
Gregory Nutt
9546481054 Fix some typographical errors. 2018-09-14 06:55:45 -06:00
ligd
e840038f2d net/ and include/nuttx/net: Add getpeername() support 2018-07-19 07:16:30 -06:00
Gregory Nutt
706a6a2c19 Trivial typo fixes 2018-06-23 06:20:25 -06:00
Gregory Nutt
b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Dmitriy Linikov
a8c58607e9 Merged in hardlulz/modem-3.0-nuttx/fix-sem-EINTR (pull request #603)
Added ECANCELED condition to DEBUGASSERT-s checking sem_wait result

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2018-02-20 18:24:53 +00:00
Gregory Nutt
2683f713ab Make sure that labeling is used consistently in all function headers (part 3). 2018-02-01 12:17:03 -06:00
Gregory Nutt
7cf88d7dbd Make sure that labeling is used consistently in all function headers. 2018-02-01 10:00:02 -06:00
Gregory Nutt
21041af8a7 This commit modifies the Unix domain local socket design. Local sockets are built on top of pipes. The Local socket implementation maintained file descriptors to interrupt with the pipes. File descriptors have the bad property that they are valid only while running on the thread within the task that created the local socket.
As a policy, all internal OS implementations must use "detached" files which are valid in any context and do not depend on the validity of a file descriptor at any point in time.  This commit converts the usage of file descriptors to detached files throughout the local socket implementation.

Squashed commit of the following:

    net/local: Finish change to eliminate use of file descriptors.
    net/local:  A little more of the conversion.
    net/local: Beginning of chnages to eliminate use of file descriptors in the local socket implementeation. poll() will be a problem.
2017-11-02 08:23:38 -06:00
Juha Niskanen
31f3f990c3 net/local: fix typo in config macro name 2017-10-25 07:23:48 -06:00
Gregory Nutt
6de41b6cf3 net/local: Missed at least one change from read() to nx_read(). 2017-10-11 12:16:00 -06:00
Gregory Nutt
a00d8e16a1 Adds OS internal function nx_write() which is functionally equivalent to write() except that it does not set the errno variable and do not cause cancellation points. 2017-10-11 10:18:30 -06:00
Gregory Nutt
6a13faf702 net/local: Need to include nuttx/semaphore.h to eliminate some new warnings. 2017-10-08 13:31:03 -06:00
Gregory Nutt
9568600ab1 Squashed commit of the following:
This commit backs out most of commit b4747286b1.  That change was added because sem_wait() would sometimes cause cancellation points inappropriated.  But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.

    In the OS, all calls to sem_wait() changed to nxsem_wait().  nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.

    In all OS functions (not libraries), change sem_wait() to nxsem_wait().  This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.

    sched/semaphore:  Add the function nxsem_wait().  This is a new internal OS interface.  It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
2017-10-04 15:22:27 -06:00
Gregory Nutt
42a0796615 Squashed commit of the following:
sched/semaphore:  Add nxsem_post() which is identical to sem_post() except that it never modifies the errno variable.  Changed all references to sem_post in the OS to nxsem_post().

    sched/semaphore:  Add nxsem_destroy() which is identical to sem_destroy() except that it never modifies the errno variable.  Changed all references to sem_destroy() in the OS to nxsem_destroy().

    libc/semaphore and sched/semaphore:  Add nxsem_getprotocol() and nxsem_setprotocola which are identical to sem_getprotocol() and set_setprotocol() except that they never modifies the errno variable.  Changed all references to sem_setprotocol in the OS to nxsem_setprotocol().  sem_getprotocol() was not used in the OS
2017-10-03 15:35:24 -06:00
Gregory Nutt
83cdb0c552 Squashed commit of the following:
libc/semaphore:  Add nxsem_getvalue() which is identical to sem_getvalue() except that it never modifies the errno variable.  Changed all references to sem_getvalue in the OS to nxsem_getvalue().

    sched/semaphore:  Rename all internal private functions from sem_xyz to nxsem_xyz.  The sem_ prefix is (will be) reserved only for the application semaphore interfaces.

    libc/semaphore:  Add nxsem_init() which is identical to sem_init() except that it never modifies the errno variable.  Changed all references to sem_init in the OS to nxsem_init().

    sched/semaphore:  Rename sem_tickwait() to nxsem_tickwait() so that it is clear this is an internal OS function.

    sched/semaphoate:  Rename sem_reset() to nxsem_reset() so that it is clear this is an internal OS function.
2017-10-03 12:52:31 -06:00
Jussi Kivilinna
8042c96f09 net/local: fix server lc_waitsem overflow 2017-09-01 07:47:29 -06:00
Gregory Nutt
7ebef900fb Networking: Fix a race condition. The accept() operation is performed with the network locked. However, the network is unlocked BEFORE the connected state is set. Therefore, a context switch may occur and the socket may no longer be connected when it is marked so. Noted by Pascal Speck. 2017-08-31 07:23:19 -06:00
Jussi Kivilinna
52becb7811 net/local: fix accept for local stream sockets 2017-07-31 07:36:54 -06:00
Simon Piriou
d88dc9b2e5 net_pkt: fix typo and symbol collision 2017-07-22 09:01:24 -06:00
Gregory Nutt
c964cd4612 Socket interface: Fix some configuration chaos. Sometime CONFIG_NET_UDP/TCP was used when CONFIG_NET_LOCAL_DGRAM/STREAM was intended. 2017-07-14 12:36:54 -06:00
Gregory Nutt
b4467a5cf5 Socket I/F: Fixes to LOCAL socket interface to get sim/udgram to build. 2017-07-14 11:34:34 -06:00
Gregory Nutt
8bf8c3fa86 Socket I/F: Add address family support for poll() and sendfile() 2017-07-14 10:57:38 -06:00
Gregory Nutt
ac543648b8 Socket interface: Added getsockname[C() interfaces. 2017-07-14 09:04:19 -06:00
Simon Piriou
ac72978072 Networking: Fix typos introduced with network interface changes. 2017-07-14 06:02:49 -06:00
Gregory Nutt
5033a6def7 Socket interface: Added addref() and sockcaps() interfaces. 2017-07-13 13:36:18 -06:00
Gregory Nutt
833ee2275d Socket interface: Added close() interface. 2017-07-13 12:15:15 -06:00
Gregory Nutt
0c840ed22f Socket interface: Added listen() and accept() interfaces. 2017-07-13 11:15:00 -06:00
Gregory Nutt
85b1ae4cf0 Socket interface: Added bind() and connect() interfaces. 2017-07-13 09:28:18 -06:00
Gregory Nutt
a71c504142 Socket I/F: Add recvfrom() method to interface. 2017-07-12 17:36:05 -06:00
Gregory Nutt
1b9cb70828 Sockets: Initial steps to adde a socket interface to the networking. Each address family will have an interface that describes how to perform socket operations on that address family. Currently only a couple of methods are defined in the table as a proof of concept. More to come. Currently there are only tables for the INET/INET6 family, the Unix LOCAL family, and the raw PACKET family. Hopefully there will be AF_IEEE802154 and AF_BLUETOOTH comming down the pike. 2017-07-12 15:07:32 -06:00
Gregory Nutt
d5207efb5a Be consistent... Use Name: consistent in function headers vs Function: 2017-04-21 16:33:14 -06:00
Juha Niskanen
21545ab643 net/local: connect: Fix warning with gcc-arm-none-eabi-5-2016q1. Using compiler from gcc-arm-none-eabi-5-2016q1 toolchain:
gcc version 5.3.1 20160307 (release) [ARM/embedded-5-branch revision 234589] (GNU Tools for ARM Embedded Processors)

gives error:

  local/local_connect.c:188:7: error: '_local_semtake' is static but used in inline function 'local_stream_connect' which is not static [-Werror]

this is due to compiler enforcing ISO/IEC 9899:1999 6.7.4.3:  "An inline definition of a function with external linkage shall not contain a definition of a modifiable object with static storage duration, and shall not contain a reference to an identifier with internal linkage."

Fix by making inlined caller to have internal linkage as well.
2017-03-30 06:54:59 -06:00
Gregory Nutt
f45727dffc Fix some kruft left behind in last big commit. 2016-12-03 16:53:31 -06:00
Gregory Nutt
7467329a98 Eliminate CONFIG_NO_NOINTS. Lots of files changed -> lots of testing needed. 2016-12-03 16:28:19 -06:00
Gregory Nutt
2d057c28c8 net: Disable priority inheritance on all semaphores used for signaling 2016-11-03 12:17:02 -06:00
Gregory Nutt
9a44f3017b Fix a few typos in the last commit 2016-07-19 13:40:54 -06:00
Gregory Nutt
6e6c04f778 Rename file_poll as fdesc_poll. The file_ namespace is used for other things. 2016-07-15 11:21:11 -06:00
Gregory Nutt
f4fcdcdb4d net/: Change some *err() message to *info() messages if what was a *dbg() message does not indicate and error condition. 2016-06-11 17:37:21 -06:00
Gregory Nutt
a1469a3e95 Add CONFIG_DEBUG_ERROR. Change names of *dbg() * *err() 2016-06-11 15:50:49 -06:00
Gregory Nutt
fc3540cffe Replace all occurrences of vdbg with vinfo 2016-06-11 11:59:51 -06:00
Gregory Nutt
bcbd8ee964 Networking: Cosmetic change 2016-02-24 19:02:51 -06:00
Gregory Nutt
6209c51206 net/: More clean-up of spacing/alignment issues 2015-10-08 15:10:04 -06:00
Gregory Nutt
af086c40ff Remove dangling whitespace 2015-10-04 15:28:54 -06:00
Gregory Nutt
0b12dbf95d Fix some spacing problems 2015-10-04 15:04:00 -06:00
Gregory Nutt
fca919f3d2 Networking: Fix some compilation issues noted with network is build with CONFIG_BUILD_KERNEL 2015-07-05 11:18:56 -06:00
Gregory Nutt
342f5fe33d Fix references to the no-longer-existent misc/ directory in comments, README files, and documentation 2015-06-28 08:08:57 -06:00
Gregory Nutt
0f5c35260b Local sockets: Local stream sockets had problem of double releasing pipes (both server and client attempt release), which causes wrong pipe pair being closed in multi-client case. Solve by adding per connection instance ID to pipe names. From Jussi Kivilinna (2015-05-12). 2015-05-12 07:47:32 -06:00
Gregory Nutt
3c1af2feed Local sockets: Add poll support for Unix stream sockets. From Jussi Kivilinna. 2015-05-12 07:41:12 -06:00
Gregory Nutt
2fcb93d2ca Correct some network lock logic: Two error conditions where the network was not being unlocked and one where it was getting unlocked twice. From Jussi Kivilinna. 2015-05-12 07:28:26 -06:00
Gregory Nutt
63ab39b274 VFS: The inode unlink method should not be support if operations on the root pseudo-filesystem are disabled. 2015-02-18 09:34:58 -06:00
Gregory Nutt
011ff49685 Cosmetic update to a few comments 2015-02-01 12:23:57 -06:00
Gregory Nutt
898d511e05 Unix domain: Fix some bugs in logic the frees stream FIFOs 2015-02-01 09:16:55 -06:00
Gregory Nutt
f8bb77365a Unix domain: Enable logic to clean up the FIFOs underlying stream sockets with those sockets are disconnected. Tehre is still no corresponding clean-up logic in place for Unix domain datagram sockets because the life of the FIFO is not as well known in that case 2015-02-01 08:52:26 -06:00
Gregory Nutt
0fc8d2fcc5 Unix domain: Add options to build in stream or datagram support separately 2015-01-31 07:58:51 -06:00
Gregory Nutt
f421723fbd Fix some errors in debug assertions 2015-01-30 13:29:56 -06:00
Gregory Nutt
62b706fa68 If a Unix domain socket is non-blocking, then the underlying FIFO should also be opened non-blocking 2015-01-30 12:43:37 -06:00
Gregory Nutt
e8a74527a0 Fix mimatched #if/#endif 2015-01-30 12:28:29 -06:00
Gregory Nutt
e86d00913e Unix domain/FIFOs: Fix a race condition between FIFO buffer operations and the opening and closing of FIFOs which necessary when the FIFOs are used to support Unix domain, datagram sockets. The default policy is the deallocate FIFO buffering when the last client closes the pipe. When when used for datagram communicatinos, packets left in the FIFO will be lost. Some like UDP read-ahead is needed: The buffered data in the FIFO needs to be retained until the reader gets a chance to re-open the FIFO. Added an ioctl (PIPEIOC_POLICY) to control the buffer policy. Default (0) is the legacy behavior; Unix domain datagram logic sets the alternative policy so that the packet data persists after the FIFO is closed. 2015-01-30 11:14:24 -06:00
Gregory Nutt
2a39105b3f Unix domain: Add logic to release references to the half duplex FIFO after sendto and recvfrom 2015-01-30 09:28:55 -06:00
Gregory Nutt
de91d34a19 Networking: Separate out UDP poll logic from socket/net_poll.c into a new udp/udp_netpoll.c; Create a skeleton local/local_netpoll.c for future poll support on Unix domain sockets. 2015-01-30 07:09:25 -06:00
Gregory Nutt
0deca5b039 Unix domain: Various fixes to get apps/examplex/udgram working 2015-01-29 11:05:04 -06:00
Gregory Nutt
e5f820a2cd Unix domain: Add sendto logic for SOCK_DRAM protocoal 2015-01-29 10:40:10 -06:00
Gregory Nutt
ffb16f658f Unix domain: Add initial cut at redvfrom() for Unix domain datagram sockets 2015-01-29 07:47:09 -06:00
Gregory Nutt
dfa642601a Merge remote-tracking branch 'origin/master' into afunix 2015-01-28 14:58:49 -06:00
Gregory Nutt
2c7123197c Networking: Move UDP-specifc parts of sendto() out of socket/sendto.c and into udp/udp_sendto.c. Hook in Unix domain sokcet sendto() logic (still just a stub for the moment) 2015-01-28 13:41:24 -06:00
Gregory Nutt
508f8aefa6 Unix domain socket support is no longer EXPERIMENTAL 2015-01-28 13:22:53 -06:00
Gregory Nutt
cba78c7349 Unix domain: More fixes. With these changes, apps/examples/ustream works 2015-01-28 08:39:48 -06:00
Gregory Nutt
b76db036da Unix domain: A few more bugfixes 2015-01-27 17:31:42 -06:00
Gregory Nutt
ca2102febb Unix domain: A few fixes from early integration 2015-01-27 16:39:30 -06:00
Gregory Nutt
8f29039f42 Unix sockets: Fleshes out the recvfrom() logic 2015-01-27 11:51:24 -06:00
Gregory Nutt
120efa4717 Local sockets: Add basic packet send logic 2015-01-27 08:05:09 -06:00
Gregory Nutt
1f7b40ce15 Local sockets: Remove some ill-conceived logic 2015-01-27 07:03:20 -06:00
Gregory Nutt
2201c9b449 Add stub files for sending and receiving on FIFOs 2015-01-26 17:28:36 -06:00
Gregory Nutt
1828badd1d Networking: Add FIFO management logic needed to support Unix domain sockets 2015-01-26 13:30:27 -06:00
Gregory Nutt
a25f6cb7fd Replace an un-necessary goto 2015-01-25 17:53:01 -06:00
Gregory Nutt
f756545eb0 Networking: Add local Unix domain socket accept logic 2015-01-25 16:27:25 -06:00
Gregory Nutt
90e59217c6 Networking: Move TCP specific logic out of net/socket/accept.c to net/tcp/tcp_accept.c; add hooks for local, Unix doamin sockets 2015-01-25 15:46:05 -06:00
Gregory Nutt
59f9a1a286 Networking: Add local Unix domain socket listen logic 2015-01-25 14:16:44 -06:00
Gregory Nutt
c3f2023089 Networking: Add local Unix domain socket connection logic 2015-01-25 12:37:40 -06:00
Gregory Nutt
ffc02f30b0 Networking: Add logic for binding Unix domain sockets 2015-01-25 08:33:39 -06:00
Gregory Nutt
3b64518049 Networking: A litle more Unix domain socket logic 2015-01-25 07:36:16 -06:00
Gregory Nutt
666ee755da Hook local socket functions into socket creation and close logic 2015-01-24 15:19:50 -06:00
Gregory Nutt
81a3daca6d Add basic build structure for Unix domain sockets 2015-01-24 14:03:32 -06:00