swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.44k stars 3.16k forks source link

fwrite() in Event Handler #5521

Open zaunere opened 3 days ago

zaunere commented 3 days ago

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error. Writing to a log file from event handler.

If I remove the plog() call - which fwrite() to a file - it works; otherwise the errors below.

  ioev::reader($client->socket,function( $socket ) use ($client,$_si,$shmap,$proc) {
      plog("{$proc->name} reading from {$_si['name']}");
      (WSS_IN)($_si,$client,$shmap,$proc);
  });
  1. What did you expect to see? The log entry.

  2. What did you see instead?

    =250834 | line:63 | Error Code: 17
    =250834 | line:63 | Error Code: 5001
    =250834 | line:63 | Client no connection
  3. What version of Swoole are you using (show your php --ri swoole)?

    
    Author => Swoole Team <team@swoole.com>
    Version => 6.0.0-dev
    Built => Oct 17 2024 16:47:46
    coroutine => enabled with boost asm context
    epoll => enabled
    eventfd => enabled
    thread => enabled
    signalfd => enabled
    cpu_affinity => enabled
    spinlock => enabled
    rwlock => enabled
    sockets => enabled
    openssl => OpenSSL 3.1.4 24 Oct 2023
    dtls => enabled
    http2 => enabled
    json => enabled
    curl-native => enabled
    c-ares => 1.28.1
    zlib => 1.2.13
    brotli => E16781312/D16781312
    mutex_timedlock => enabled
    pthread_barrier => enabled
    futex => enabled

Directive => Local Value => Master Value swoole.enable_library => On => On swoole.enable_fiber_mock => Off => Off swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => On => On swoole.unixsock_buffer_size => 8388608 => 8388608


5. What is your machine environment used (show your `uname -a` & `php -v` & `gcc -v`) ?

Linux qubit 6.11.3-100.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Oct 10 20:49:51 UTC 2024 x86_64 GNU/Linux

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.3.1-20240913/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.3.1 20240913 (Red Hat 13.3.1-3) (GCC)

PHP 8.5.0-dev (cli) (built: Oct 17 2024 16:44:01) (ZTS) Copyright (c) The PHP Group Zend Engine v4.5.0-dev, Copyright (c) Zend Technologies

NathanFreeman commented 1 day ago

I will take a look later.