struct sock is different though. callbacks are inside.
>The sk thing looks reasonable at first glance. Getting a reference to
>npf->owner, then holding it for the socket is a little confusing, but
>an obvious optimization over a naive "get, use, drop, get".
That was an optimization indeed. There is no point in dropping reference
there.
>In sys_accept:
>
>> @@ -1196,9 +1198,13 @@
>> if (!(newsock = sock_alloc()))
>> goto out_put;
>>
>> - newsock->type = sock->type;
>> - newsock->ops = sock->ops;
>> + newsock->type = sock->type;
>> + newsock->ops = sock->ops;
>> + newsock->owner = sock->owner;
>>
>> + try_module_get(sock->owner);
>> + newsock->owner = sock->owner;
>> +
>> err = sock->ops->accept(sock, newsock, sock->file->f_flags);
>> if (err < 0)
>> goto out_release;
>
>You still need to check the result of try_module_get, and fail if it
>fails. The *only* time this will fail is when someone is doing an
>"rmmod --wait" on the module, which presumably means they really do
>not want you to increase the reference count furthur.
Ohh, I see. My assumption here was that we know for sure
that module is alive at this point since we already hold a reference to the
first socket. Actually I was going to send another email and ask for unconditional
module_get() specifically for the cases like that.
Even after your explanation I still think we need unconditional module_get() there.
Because in this case 'rmmod --wait' will simply brake accept() logic. I mean it'll
keep waiting until listening socket is destroyed (i.e. until socket app is killed)
but accept() will mysteriously fail for no good reason.
Comments ?
Max
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/