If you are forking and exiting the parent immediately, I'd suggest avoid
doing any gRPC setup in the parent process.

The suggested changes were intended to avoid invoking the Server
destructor.  I suspect whats happening is std::unique_ptr<> is causing the
destructor to be called on exit().

That being said, I'd still recommend deferring server construction to the
child process.

On Tue, Mar 7, 2017 at 2:08 PM, AK <[email protected]> wrote:

> You are right about parent exiting. Sorry, that might have caused
> confusion. Actually the child becomes daemon now. Does that change how
> secure handshake in grpc behaves ?
> The builder.BuildAndStart() returns std::unqiue_ptr.
> Your suggested changes seems to make no difference to process state.
>
> On Tuesday, March 7, 2017 at 1:47:52 PM UTC-8, Ken Payson wrote:
>>
>> I'm not familiar with the interaction of unique_ptr<> and exit().
>>
>> What happens if you try the following:
>>
>>    grpc::Server* server_ptr = builder.BuildAndStart();
>>    int childpid = fork();
>>     if ( childpid )
>>       exit(0);
>>    server = std::unique_ptr<grpc::Server>(server_ptr);
>>
>>
>> Also, in the problem you stated, it sounded like you were forking and
>> exiting the child immediately.  The code provided exits the parent process
>> immediately.
>>
>>
>>
>> On Tue, Mar 7, 2017 at 1:32 PM, AK <[email protected]> wrote:
>>
>>> No. The child does nothing but exit. Below is an example of what I am
>>> doing. If I move the server startup line to the end, everything works fine.
>>>
>>>    server = std::unique_ptr<grpc::Server>(builder.BuildAndStart());
>>>    int childpid = fork();
>>>     if ( childpid )
>>>       exit(0);
>>>
>>>
>>> On Tuesday, March 7, 2017 at 1:03:01 PM UTC-8, Ken Payson wrote:
>>>>
>>>> Are you calling any destructors in the forked process before exit?
>>>> Destroying the server will call shutdown() on the underlying sockets, which
>>>> will cause problems for the parent process.
>>>>
>>>> Ken
>>>>
>>>> On Tue, Mar 7, 2017 at 12:19 PM, AK <[email protected]> wrote:
>>>>
>>>>> The forked child simply exits leaving the parent as daemon. I am doing
>>>>> it in C++ on Ubuntu.
>>>>>
>>>>> On Tuesday, March 7, 2017 at 12:07:40 PM UTC-8, Nicolas Noble wrote:
>>>>>>
>>>>>> Does the forked child do any gRPC call at all ? Also, which language ?
>>>>>>
>>>>>> On Tue, Mar 7, 2017 at 9:40 AM, AK <[email protected]> wrote:
>>>>>>
>>>>>>>
>>>>>>> I am trying to make grpc server a daemon by forking a child and
>>>>>>> making it exit. But after that the client handshake starts to fail.
>>>>>>>
>>>>>>> E0307 01:15:58.221786152   27094 handshake.c:128]
>>>>>>> Security handshake failed: 
>>>>>>> {"created":"@1488878158.221756436","description":"Handshake
>>>>>>> read failed","file":"src/core/lib/security/transport/handshake.c"
>>>>>>> ,"file_line":237,"referenced_errors":[{"created":"@
>>>>>>> 1488878158.221740996","description":"FD
>>>>>>> shutdown","file":"src/core/lib/iomgr/ev_epoll_linux.c","file
>>>>>>> _line":948}]}
>>>>>>>
>>>>>>> This happens if fork() is called after the call to BuildAndStart().
>>>>>>> If the same fork is done before BuildAndStart() everything works fine.
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "grpc.io" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to [email protected].
>>>>>>> To post to this group, send email to [email protected].
>>>>>>> Visit this group at https://groups.google.com/group/grpc-io.
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/grpc-io/1d59f06c-bdad-4a00
>>>>>>> -9f01-1abcd59a7cbc%40googlegroups.com
>>>>>>> <https://groups.google.com/d/msgid/grpc-io/1d59f06c-bdad-4a00-9f01-1abcd59a7cbc%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "grpc.io" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at https://groups.google.com/group/grpc-io.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/grpc-io/c2f99403-4ac5-43bf
>>>>> -b9cf-cfdc3eb149da%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/grpc-io/c2f99403-4ac5-43bf-b9cf-cfdc3eb149da%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "grpc.io" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/grpc-io.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/grpc-io/d951fc71-6415-465a-9f56-bf4112c926e1%40googlegroups.com
>>> <https://groups.google.com/d/msgid/grpc-io/d951fc71-6415-465a-9f56-bf4112c926e1%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups "
> grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/grpc-io/653cb90f-2322-4032-be3b-fa202469ac2d%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/653cb90f-2322-4032-be3b-fa202469ac2d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/CAGm2-Y7DvaF_a6Qk%3DCZdG9Ddj2Bjsr_yBXmfFZ-WFdVJcwS4yg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to