title: Firebird 2.5 Events "error writing data to the connection"
body: <p>I am using the latest <code>Firebird 2.5.3</code> on OSX10.10 using the C api, and have an issued I've narrowed specifically to events. I get </p>
  
  <pre><code>"error writing data to the connection"
  </code></pre>
  
  <p>with ~1:5 probability of happening on an event that is run from a database trigger using:</p>
  
  <pre><code>POST_EVENT 'xxx';                
  </code></pre>
  
  <p>where 'xxx' is the Event_Callback</p>
  
  <p>Is this an issue others are seeing? I'm having a hard time tracking much info down using google, as most references are for earlier versions of Firebird, or for supposedly 'fixed' bugs.</p>
  
  <p><strong>edit - additional info</strong></p>
  
  <p>obviously, some of the details have been </p>
  
  <p>The trigger is created with something akin to:</p>
  
  <pre><code>"CREATE TRIGGER \"%s\" FOR \"%s\"   \
                  AFTER %s                        \
               AS                                 \
                BEGIN                             \
                  if( new.id = %d ) THEN          \
                      BEGIN                       \
                          INSERT INTO \"Event_Log\" (\"ID\",\"triggerName\", \"lastModified\") VALUES (GEN_ID(\"seq_Event_Table\",1)'%s', (select current_timestamp from rdb$database) );    \
                          POST_EVENT '%s';        \
                      END                         \
                END;" 
  </code></pre>
  
  <p>Events are initialized with code that executes:</p>
  
  <pre><code>  isc_que_events(status, &amp;database, &amp;eventData-&gt;id, eventData-&gt;length, eventData-&gt;buffer, (isc_callback)EventCallback, eventData-&gt;resultBuffer);
  </code></pre>
  
  <p>And finally the event is structured:</p>
  
  <pre><code>    isc_callback EventCallback( char *result, short length, char *updated )
  {
      uint64_t startTime;
      startTime = mach_absolute_time();
      printf("__EVENT__:%s:%s:%llu\n",eventData-&gt;buffer,eventData-&gt;resultBuffer,startTime);
  
      while (length--)
      {
          *result++ = *updated++;
      }
  
      isc_event_counts(status, eventData-&gt;length, eventData-&gt;buffer, eventData-&gt;resultBuffer);
  
      isc_que_events(status, &amp;database, &amp;eventData-&gt;id, eventData-&gt;length, eventData-&gt;buffer, (isc_callback)EventCallback, eventData-&gt;resultBuffer);
      return(0);
  }
  </code></pre>
  
  <p>Finally, the code is tested by repeatedly tripping the trigger in a test suite similar to:</p>
  
  <pre><code>query = "UPDATE table_name SET column1=value1 WHERE some_column=some_value;";
  for (int i=0 ; i&lt;1e6 ; i++)
  {
  if (isc_start_transaction(status_vector, &amp;transactionHandle, 1, &amp;database, 0, NULL))                      
      {
          /*error handling*/
      }
  
  if (isc_dsql_execute_immediate(status_vector, &amp;database, &amp;transactionHandle, 0, query, 3, NULL))
      {
          /*error handling*/
      }
  
  if (isc_commit_transaction(status_vector, &amp;transactionHandle))
      {
          /*error handling*/
      }
  }
  </code></pre>