Merge pull request #12766 from miri64/gnrc_netapi/enh/report-error
gnrc_netapi: report errors on dispatch
This commit is contained in:
commit
5b608ef712
@ -18,6 +18,8 @@
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "mbox.h"
|
#include "mbox.h"
|
||||||
#include "msg.h"
|
#include "msg.h"
|
||||||
#include "net/gnrc/netreg.h"
|
#include "net/gnrc/netreg.h"
|
||||||
@ -91,20 +93,20 @@ int gnrc_netapi_dispatch(gnrc_nettype_t type, uint32_t demux_ctx,
|
|||||||
|
|
||||||
while (sendto) {
|
while (sendto) {
|
||||||
#if defined(MODULE_GNRC_NETAPI_MBOX) || defined(MODULE_GNRC_NETAPI_CALLBACKS)
|
#if defined(MODULE_GNRC_NETAPI_MBOX) || defined(MODULE_GNRC_NETAPI_CALLBACKS)
|
||||||
int release = 0;
|
uint32_t status = 0;
|
||||||
switch (sendto->type) {
|
switch (sendto->type) {
|
||||||
case GNRC_NETREG_TYPE_DEFAULT:
|
case GNRC_NETREG_TYPE_DEFAULT:
|
||||||
if (_gnrc_netapi_send_recv(sendto->target.pid, pkt,
|
if (_gnrc_netapi_send_recv(sendto->target.pid, pkt,
|
||||||
cmd) < 1) {
|
cmd) < 1) {
|
||||||
/* unable to dispatch packet */
|
/* unable to dispatch packet */
|
||||||
release = 1;
|
status = EIO;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef MODULE_GNRC_NETAPI_MBOX
|
#ifdef MODULE_GNRC_NETAPI_MBOX
|
||||||
case GNRC_NETREG_TYPE_MBOX:
|
case GNRC_NETREG_TYPE_MBOX:
|
||||||
if (_snd_rcv_mbox(sendto->target.mbox, cmd, pkt) < 1) {
|
if (_snd_rcv_mbox(sendto->target.mbox, cmd, pkt) < 1) {
|
||||||
/* unable to dispatch packet */
|
/* unable to dispatch packet */
|
||||||
release = 1;
|
status = EIO;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@ -115,16 +117,16 @@ int gnrc_netapi_dispatch(gnrc_nettype_t type, uint32_t demux_ctx,
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
/* unknown dispatch type */
|
/* unknown dispatch type */
|
||||||
release = 1;
|
status = ECANCELED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (release) {
|
if (status != 0) {
|
||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release_error(pkt, status);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (_gnrc_netapi_send_recv(sendto->target.pid, pkt, cmd) < 1) {
|
if (_gnrc_netapi_send_recv(sendto->target.pid, pkt, cmd) < 1) {
|
||||||
/* unable to dispatch packet */
|
/* unable to dispatch packet */
|
||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release_error(pkt, EIO);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
sendto = gnrc_netreg_getnext(sendto);
|
sendto = gnrc_netreg_getnext(sendto);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user