On 07/18/2017 01:18 PM, Nadav Har'El wrote:
Thanks. One question below:

On Tue, Jul 18, 2017 at 12:16 PM, Justin Cinkelj <[email protected] <mailto:[email protected]>> wrote:

    nginx doesn't start if ioctl with cmd=FIOASYNC fails. Stub it, so that
    nginx can start unpatched.

    Signed-off-by: Justin Cinkelj <[email protected]
    <mailto:[email protected]>>
    ---
     libc/af_local.cc | 18 +++++++++++++-----
     1 file changed, 13 insertions(+), 5 deletions(-)

    diff --git a/libc/af_local.cc b/libc/af_local.cc
    index b68c2b0..e65e2b1 100644
    --- a/libc/af_local.cc
    +++ b/libc/af_local.cc
    @@ -19,6 +19,8 @@
     #include <utility>
     #include <sys/ioctl.h>

    +#include <osv/stubbing.hh>
    +
     using namespace std;

     struct af_local final : public special_file {
    @@ -42,11 +44,17 @@ int af_local::ioctl(u_long cmd, void *data)
         int error = ENOTTY;
         switch (cmd) {
         case FIONBIO:
    -        SCOPE_LOCK(f_lock);
    -        if (*(int *)data)
    -            f_flags |= FNONBLOCK;
    -        else
    -            f_flags &= ~FNONBLOCK;
    +        {
    +            SCOPE_LOCK(f_lock);
    +            if (*(int *)data)
    +                f_flags |= FNONBLOCK;
    +            else
    +                f_flags &= ~FNONBLOCK;
    +        }



Why did you need to change this? did SCOPE_LOCK not work inside a "case", so you needed to add this extra scope?
Compiler complained about breaking/jumping out of case. Adding extra {} was the easiest solution.

libc/af_local.cc: In member function ‘virtual int af_local::ioctl(u_long, void*)’:
libc/af_local.cc:56:10: error: jump to case label [-fpermissive]
     case FIOASYNC:
          ^
In file included from libc/pipe_buffer.hh:15:0,
                 from libc/af_local.cc:9:
include/osv/mutex.h:109:49: note: crosses initialization of ‘std::lock_guard<lockfree::mutex> _SCOPE_LOCK0’ std::lock_guard<decltype(lock)> CONCATENATE(_SCOPE_LOCK, __COUNTER__) (lock)
                                                 ^
include/osv/mutex.h:106:28: note: in definition of macro ‘CONCATENATE2’
 #define CONCATENATE2(x, y) x##y
                            ^
include/osv/mutex.h:109:37: note: in expansion of macro ‘CONCATENATE’
std::lock_guard<decltype(lock)> CONCATENATE(_SCOPE_LOCK, __COUNTER__) (lock)
                                     ^~~~~~~~~~~
libc/af_local.cc:48:13: note: in expansion of macro ‘SCOPE_LOCK’
             SCOPE_LOCK(f_lock);
             ^~~~~~~~~~
make: *** [build/debug.x64/libc/af_local.o] Error 1

I could also move SCOP_LOCK to function level. But that is not needed for the additional FIOASYNC stub. And if later additional cases are added, then those might not need that lock, so I didn't want to do that.

    +        error = 0;
    +        break;
    +    case FIOASYNC:
    +        WARN_ONCE("af_local::ioctl(FIOASYNC) stubbed\n");


I'm surprised nginx needed this in AF_LOCAL (i.e., unix domain sockets), not on normal TCP/IP sockets. All the more reason to think it is't important :-)
Socket is created by
if (socketpair(AF_UNIX, SOCK_STREAM, 0, ngx_processes[s].channel) == -1)
I guess it is used for interprocess communication. Maybe only to coordinate at app shutdown, maybe for more things.

             error = 0;
             break;
         }
    --
    2.9.4

    --
    You received this message because you are subscribed to the Google
    Groups "OSv Development" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to [email protected]
    <mailto:osv-dev%[email protected]>.
    For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.



--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to