Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Issue 24409004: Disconnect native messaging port on read pipe EOF. (Closed)

Created:
7 years, 3 months ago by Sergey Ulanov
Modified:
7 years, 2 months ago
Reviewers:
wtc, Matt Perry, akalin
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org
Visibility:
Public.

Description

Disconnect native messaging port on read pipe EOF. Previously native messaging ports were kept open even after native messaging host has closed stdout pipe which is used to send messages to the connected webapp. That behavior makes it hard to detect the case when the host exists but fails to start. Now chrome will close the native messaging port as soon as it reads EOF from the pipe. BUG=297380 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=225418

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Patch Set 4 : #

Patch Set 5 : #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+70 lines, -28 lines) Patch
M chrome/browser/extensions/api/messaging/native_message_process_host.h View 1 1 chunk +0 lines, -3 lines 0 comments Download
M chrome/browser/extensions/api/messaging/native_message_process_host.cc View 1 2 3 4 5 chunks +6 lines, -5 lines 4 comments Download
M chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc View 1 2 3 4 5 chunks +61 lines, -16 lines 0 comments Download
M chrome/test/data/extensions/api_test/native_messaging/test.js View 1 chunk +1 line, -4 lines 0 comments Download
M net/base/net_errors_win.cc View 1 2 3 4 1 chunk +2 lines, -0 lines 1 comment Download

Messages

Total messages: 15 (0 generated)
Sergey Ulanov
7 years, 3 months ago (2013-09-24 19:04:39 UTC) #1
Matt Perry
lgtm
7 years, 3 months ago (2013-09-24 20:27:36 UTC) #2
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/sergeyu@chromium.org/24409004/38001
7 years, 2 months ago (2013-09-24 23:11:48 UTC) #3
commit-bot: I haz the power
Retried try job too often on win7_aura for step(s) unit_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=win7_aura&number=82586
7 years, 2 months ago (2013-09-25 01:32:12 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/sergeyu@chromium.org/24409004/38001
7 years, 2 months ago (2013-09-25 01:51:28 UTC) #5
Sergey Ulanov
+akalin - Fred, please approve net/base change.
7 years, 2 months ago (2013-09-25 20:02:28 UTC) #6
akalin
lgtm for net/base, but i'd like wtc@ to double-check since I'm not that familiar with ...
7 years, 2 months ago (2013-09-25 21:48:03 UTC) #7
wtc
Patch set 5 LGTM. https://codereview.chromium.org/24409004/diff/82001/chrome/browser/extensions/api/messaging/native_message_process_host.cc File chrome/browser/extensions/api/messaging/native_message_process_host.cc (right): https://codereview.chromium.org/24409004/diff/82001/chrome/browser/extensions/api/messaging/native_message_process_host.cc#newcode250 chrome/browser/extensions/api/messaging/native_message_process_host.cc:250: } else if (result == ...
7 years, 2 months ago (2013-09-25 23:03:12 UTC) #8
akalin
https://codereview.chromium.org/24409004/diff/82001/chrome/browser/extensions/api/messaging/native_message_process_host.cc File chrome/browser/extensions/api/messaging/native_message_process_host.cc (right): https://codereview.chromium.org/24409004/diff/82001/chrome/browser/extensions/api/messaging/native_message_process_host.cc#newcode250 chrome/browser/extensions/api/messaging/native_message_process_host.cc:250: } else if (result == 0 || result == ...
7 years, 2 months ago (2013-09-25 23:09:32 UTC) #9
Sergey Ulanov
https://codereview.chromium.org/24409004/diff/82001/chrome/browser/extensions/api/messaging/native_message_process_host.cc File chrome/browser/extensions/api/messaging/native_message_process_host.cc (right): https://codereview.chromium.org/24409004/diff/82001/chrome/browser/extensions/api/messaging/native_message_process_host.cc#newcode250 chrome/browser/extensions/api/messaging/native_message_process_host.cc:250: } else if (result == 0 || result == ...
7 years, 2 months ago (2013-09-25 23:30:50 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/sergeyu@chromium.org/24409004/82001
7 years, 2 months ago (2013-09-26 04:09:22 UTC) #11
commit-bot: I haz the power
Change committed as 225418
7 years, 2 months ago (2013-09-26 09:31:26 UTC) #12
wtc
https://codereview.chromium.org/24409004/diff/82001/chrome/browser/extensions/api/messaging/native_message_process_host.cc File chrome/browser/extensions/api/messaging/native_message_process_host.cc (right): https://codereview.chromium.org/24409004/diff/82001/chrome/browser/extensions/api/messaging/native_message_process_host.cc#newcode250 chrome/browser/extensions/api/messaging/native_message_process_host.cc:250: } else if (result == 0 || result == ...
7 years, 2 months ago (2013-09-26 17:14:05 UTC) #13
Sergey Ulanov
On 2013/09/26 17:14:05, wtc wrote: > > Are you using an anonymous pipe and reading ...
7 years, 2 months ago (2013-09-26 17:37:40 UTC) #14
wtc
7 years, 2 months ago (2013-09-27 19:01:48 UTC) #15
Message was sent while issue was closed.
On 2013/09/26 17:37:40, Sergey Ulanov wrote:
> On 2013/09/26 17:14:05, wtc wrote:
> > 
> > If we disallow writing 0 bytes to the pipe, then we can change the
> > ERROR_BROKEN_PIPE error to a read byte count of 0 with no risk of confusion.
> > Would you be willing to do that?
> 
> This doesn't seem like a right thing to do. There may be other cases when
> ERROR_BROKEN_PIPE is returned, in which returning 0 would not be correct.

I found this example code on MSDN:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365588%28v=vs.85%29...

It tells us two things.

1. It suggests the documentation of ERROR_BROKEN_PIPE in the MSDN page for
ReadFile()
applies not only to an anonymous pipe but also to a named pipe.

2. It suggests the ERROR_BROKEN_PIPE error is only used to indicate the peer
disconnected.

So it should be safe to hide this platform difference and use a read byte count
of 0
to report this condition. In any case, I leave the decision to you.

> > Alternatively, it may be a good idea to perform the result ==
> > net::ERR_CONNECTION_RESET check on Windows only, because on Unix
> > the EPIPE or ECONNRESET error is a sign of an abrupt (not graceful)
connection
> > closure.
> 
> read() always returns 0 for not connected pipes. write() may return EPIPE, but
> it depends on state of SIGPIPE handler an SO_NOSIGPIPE option. It doesn't
matter
> how the other end of the pipe was closed.

Thanks. So I think you agree that on Unix, read() won't fail with EPIPE or
ECONNRESET
under the same condition, so the result == net::ERR_CONNECTION_RESET check can
be
made Windows only. The #if defined(OS_WIN) can make the code ugly, so I think
the
comment you just added in https://codereview.chromium.org/24806002/ is fine.

Powered by Google App Engine
This is Rietveld 408576698