Buffer BUG! CRUSHED!

From: Angus Mezick (angus@EDGIL.CCMAIL.COMPUSERVE.COM)
Date: 09/17/97


     ok... this is small and rare, but like all bugs of this type, a pain
     to dig out.
     in comm.c:heartbeat()
     I had:
     void heartbeat(int pulse)
     {
        static int mins_since_crashsave = 0;

       /* Clear out all the global buffers now in case someone forgot. */

        if (!(pulse % PULSE_ZONE))
           zone_update();

        if (!(pulse % (15 * PASSES_PER_SEC)))  /* 15 seconds */
           check_idle_passwords();

        if (!(pulse % PULSE_BUFFER))
           release_all_buffers();
     .
     .
     .
     }

     it should be:
     void heartbeat(int pulse)
     {
        static int mins_since_crashsave = 0;

       /* Clear out all the global buffers now in case someone forgot. */

        if (!(pulse % PULSE_BUFFER))
           release_all_buffers();

        if (!(pulse % PULSE_ZONE))
           zone_update();

        if (!(pulse % (15 * PASSES_PER_SEC)))  /* 15 seconds */
           check_idle_passwords();
     .
     .
     .
     }

     zone update was forcing write_to_output to give it a large_buf because
     a lot of the zones were idling out. Then, the next thing that
     heartbeat function did was try to realease_all_buffers(), thus
     releasing the large_buf before process_output could get it's hands on
     it.  you ended up with descriptor->output pointing off to 0 eek...
     just a warning for all those who use the code, DON'T put anything that
     could possibly send more then SMALL_BUFSIZE char's to the output
     between the process_output() call and the release_all_buffers() call.
     nasty things can happen.

     --Angus


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST