MCPcopy Create free account
hub / github.com/acl-dev/acl / setup_hook

Method setup_hook

lib_acl_cpp/src/stream/stream.cpp:325–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323#define HOOK_KEY "stream::setup_hook"
324
325stream_hook* stream::setup_hook(stream_hook* hook)
326{
327 if (stream_ == NULL) {
328 logger_error("stream_ null");
329 return NULL;
330 }
331
332 stream_hook* old_hook = hook_;
333
334 if (stream_->type == ACL_VSTREAM_TYPE_FILE) {
335 ACL_FSTREAM_RD_FN read_fn = stream_->fread_fn;
336 ACL_FSTREAM_WR_FN write_fn = stream_->fwrite_fn;
337
338 stream_->fread_fn = fread_hook;
339 stream_->fwrite_fn = fsend_hook;
340 acl_vstream_add_object(stream_, HOOK_KEY, this);
341
342 if (!hook->open(stream_)) {
343 // �����ʧ�ܣ���ָ�
344
345 stream_->fread_fn = read_fn;
346 stream_->fwrite_fn = write_fn;
347 acl_vstream_del_object(stream_, HOOK_KEY);
348 return hook;
349 }
350 } else {
351 ACL_VSTREAM_RD_FN read_fn = stream_->read_fn;
352 ACL_VSTREAM_WR_FN write_fn = stream_->write_fn;
353
354 stream_->read_fn = read_hook;
355 stream_->write_fn = send_hook;
356 acl_vstream_add_object(stream_, HOOK_KEY, this);
357
358 acl_tcp_set_nodelay(ACL_VSTREAM_SOCK(stream_));
359
360 if (!hook->open(stream_)) {
361 // �����ʧ�ܣ���ָ�
362
363 stream_->read_fn = read_fn;
364 stream_->write_fn = write_fn;
365 acl_vstream_del_object(stream_, HOOK_KEY);
366 return hook;
367 }
368 }
369
370 hook_ = hook;
371 return old_hook;
372}
373
374int stream::read_hook(ACL_SOCKET, void *buf, size_t len, int,
375 ACL_VSTREAM* vs, void *)

Callers 15

http_serverFunction · 0.45
echo_fiberFunction · 0.45
ssl_initFunction · 0.45
setup_sslMethod · 0.45
testFunction · 0.45
setup_sslFunction · 0.45
setup_sslFunction · 0.45
connect_serverMethod · 0.45
setup_sslMethod · 0.45
accept_callbackMethod · 0.45
setup_sslFunction · 0.45
setup_sslMethod · 0.45

Calls 4

acl_vstream_add_objectFunction · 0.85
acl_vstream_del_objectFunction · 0.85
acl_tcp_set_nodelayFunction · 0.85
openMethod · 0.45

Tested by

no test coverage detected