Beispiel #1
0
int nxmu_sendwindow(FAR struct nxbe_window_s *wnd, FAR const void *msg,
                    size_t msglen)
{
  int ret = OK;

  /* Sanity checking */

#ifdef CONFIG_DEBUG
  if (!wnd || !wnd->conn)
    {
      set_errno(EINVAL);
      return ERROR;
    }
#endif

  /* Ignore messages destined to a blocked window (no errors reported) */

  if (!NXBE_ISBLOCKED(wnd))
    {
      /* Send the message to the server */

      ret = nxmu_sendserver(wnd->conn, msg, msglen);
    }

  return ret;
}
Beispiel #2
0
int nx_block(NXWINDOW hwnd, FAR void *arg)
{
    FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
    struct nxsvrmsg_blocked_s outmsg;
    int ret = OK;

#ifdef CONFIG_DEBUG
    if (!hwnd)
    {
        set_errno(EINVAL);
        return ERROR;
    }
#endif

    /* Ignore additional attempts to block messages (no errors reported) */

    if (!NXBE_ISBLOCKED(wnd))
    {
        /* Mark the window as blocked.  This will stop all messages to the window
         * (EXCEPT the NX_SVRMSG_BLOCKED).  Blocking the messages before sending the
         * blocked message is awkward but assures that no other messages sneak into
         * the message queue before we can set the blocked state.
         */

        NXBE_SETBLOCKED(wnd);

        /* Send the message inicating that the window is blocked (and because of
         * queue also that there are no additional queue messages for the window)
         */

        outmsg.msgid = NX_SVRMSG_BLOCKED;
        outmsg.wnd   = wnd;
        outmsg.arg   = arg;

        /* Send the window message via nxmu_sendserver (vs. nxmu_sendwindow) so
         * that it will not be blocked.
         */

        ret = nxmu_sendserver(wnd->conn, &outmsg, sizeof(struct nxsvrmsg_blocked_s));
    }

    return ret;
}