@@ -84,7 +84,8 @@ class PipeChannel : public AttachOperation::RequestReader, public AttachOperatio
84
84
0 , // default attributes
85
85
nullptr ); // no template file
86
86
if (_hPipe == INVALID_HANDLE_VALUE) {
87
- log_error (attach)(" could not open (%d) pipe %s" , GetLastError (), pipe );
87
+ log_error (attach)(" could not open %s (%d) pipe %s" ,
88
+ (write_only ? " write-only" : " read-write" ), GetLastError (), pipe );
88
89
return false ;
89
90
}
90
91
return true ;
@@ -106,7 +107,11 @@ class PipeChannel : public AttachOperation::RequestReader, public AttachOperatio
106
107
(DWORD)size,
107
108
&nread,
108
109
nullptr ); // not overlapped
109
- return fSuccess ? (int )nread : -1 ;
110
+ if (!fSuccess ) {
111
+ log_error (attach)(" pipe read error (%d)" , GetLastError ());
112
+ return -1 ;
113
+ }
114
+ return (int )nread;
110
115
}
111
116
112
117
// ReplyWriter
@@ -118,7 +123,11 @@ class PipeChannel : public AttachOperation::RequestReader, public AttachOperatio
118
123
(DWORD)size,
119
124
&written,
120
125
nullptr ); // not overlapped
121
- return fSuccess ? (int )written : -1 ;
126
+ if (!fSuccess ) {
127
+ log_error (attach)(" pipe write error (%d)" , GetLastError ());
128
+ return -1 ;
129
+ }
130
+ return (int )written;
122
131
}
123
132
124
133
void flush () override {
@@ -138,12 +147,12 @@ class Win32AttachOperation: public AttachOperation {
138
147
139
148
public:
140
149
// for v1 pipe must be write-only
141
- void open_pipe (const char * pipe_name, bool write_only) {
142
- _pipe.open (pipe_name, write_only);
150
+ bool open_pipe (const char * pipe_name, bool write_only) {
151
+ return _pipe.open (pipe_name, write_only);
143
152
}
144
153
145
154
bool read_request () {
146
- return AttachOperation::read_request (&_pipe);
155
+ return AttachOperation::read_request (&_pipe);
147
156
}
148
157
149
158
public:
@@ -390,13 +399,17 @@ Win32AttachOperation* Win32AttachListener::dequeue() {
390
399
for (int i = 0 ; i < AttachOperation::arg_count_max; i++) {
391
400
op->append_arg (request->arg (i));
392
401
}
393
- op->open_pipe (request->pipe (), true /* write-only*/ );
402
+ if (!op->open_pipe (request->pipe (), true /* write-only*/ )) {
403
+ // error is already logged
404
+ delete op;
405
+ op = nullptr ;
406
+ }
394
407
break ;
395
408
case ATTACH_API_V2:
396
409
op = new Win32AttachOperation ();
397
- op->open_pipe (request->pipe (), false /* write-only*/ );
398
- if ( !op->read_request ()) {
399
- log_error (attach)( " AttachListener::dequeue, reading request ERROR " );
410
+ if (! op->open_pipe (request->pipe (), false /* write-only*/ )
411
+ || !op->read_request ()) {
412
+ // error is already logged
400
413
delete op;
401
414
op = nullptr ;
402
415
}
0 commit comments