I already have this commit in my branch.

My solution was:

static int local_ioctl(FAR struct socket *psock, int cmd, unsigned long arg)
{
  FAR struct local_conn_s *conn;
  int ret = -ENOTTY; // before was OK

  conn = (FAR struct local_conn_s *)psock->s_conn;

  switch (cmd)
    {
      case FIONBIO:
        if (conn->lc_infile.f_inode != NULL) // in my case this evaluate to
false
          {
            ret = file_ioctl(&conn->lc_infile, cmd, arg);
          }

        if (ret >= 0 && conn->lc_outfile.f_inode != NULL)  // in my case
this evaluate to false
          {
            ret = file_ioctl(&conn->lc_outfile, cmd, arg);
          }
        break;
      case FIONREAD:
        if (conn->lc_infile.f_inode != NULL)
          {
            ret = file_ioctl(&conn->lc_infile, cmd, arg);
          }
        else
          {
            ret = -ENOTCONN;
          }
        break;
      case FIONSPACE:
        if (conn->lc_outfile.f_inode != NULL)
          {
            ret = file_ioctl(&conn->lc_outfile, cmd, arg);
          }
        else
          {
            ret = -ENOTCONN;
          }
        break;
      default:
        ret = -ENOTTY;
        break;
    }

  return ret; // before was returning OK, now -ENOTTY
}

Function local_ioctl is called from  netdev_ioctl and if this
function returns -ENOTTY, then netdev_file_ioctl is called next, which is
then responsible to set s_flags for the socket.


On Fri, Nov 4, 2022 at 3:42 AM Xiang Xiao <xiaoxiang781...@gmail.com> wrote:

> In the old design, the driver/socket needed to return -ENOTTY to activate
> the default action(in file_vioctl) even if they handle O_NONBLOCK
> internally. This approach confuses many people and introduces the error you
> hit several times.
> So https://github.com/apache/incubator-nuttx/pull/6976 fixes this problem:
> the default action is activated when driver/socket return either OK or
> -ENOTTY.
> I suggest you cherry-pick this patch to enter the final solution.
>
> On Fri, Nov 4, 2022 at 3:00 AM Jernej Turnsek <jernej.turn...@gmail.com>
> wrote:
>
> > I think I have a fix to this problem. If I change the initialization
> > value of the variable ret in function local_ioctl (file local_sockif.c)
> > from OK to -ENOTTY (like the fix in netdev_ioctl), it starts to work in
> my
> > case. I think it should not be a problem for other cases. What do you
> > think?
> >
> > On Thu, Nov 3, 2022 at 7:04 PM Xiang Xiao <xiaoxiang781...@gmail.com>
> > wrote:
> >
> > > Does your branch contain this patch?
> > > https://github.com/apache/incubator-nuttx/pull/5933
> > >
> > > On Fri, Nov 4, 2022 at 1:11 AM Jernej Turnsek <
> jernej.turn...@gmail.com>
> > > wrote:
> > >
> > > > Hi,
> > > >
> > > > I am trying to set O_NONBLOCK flag with the help of fcntl on Local
> > Socket
> > > > structure (AF_UNIX) and I am not getting the non blocking
> > functionality.
> > > If
> > > > setting the SOCK_NONBLOCK flag while creating the socket, it is
> working
> > > > fine. I am using some Linux based code, where this functionality is
> > > > working. Is this a bug?
> > > >
> > > > Regards,
> > > > Jernej
> > > >
> > >
> >
>

Reply via email to