Changeset c6adf17


Ignore:
Timestamp:
Oct 1, 2010, 9:22:20 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
afaef6e
Parents:
385cce2
git-author:
David Benjamin <davidben@mit.edu> (09/25/10 02:02:45)
git-committer:
David Benjamin <davidben@mit.edu> (10/01/10 21:22:20)
Message:
Track names along with timers, add :show timers

This will help people with BarnOwls eating CPU to diagnose timer leaks.
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • aim.c

    rc5873be rc6adf17  
    184184  owl_function_debugmsg("owl_aim_login: connecting");
    185185
    186   g.aim_nop_timer = owl_select_add_timer(30, 30, owl_aim_send_nop, NULL, NULL);
     186  g.aim_nop_timer = owl_select_add_timer("owl_aim_send_nop", 30, 30, owl_aim_send_nop, NULL, NULL);
    187187
    188188  return(0);
     
    210210  /* start the ingorelogin timer */
    211211  owl_global_set_ignore_aimlogin(&g);
    212   owl_select_add_timer(owl_global_get_aim_ignorelogin_timer(&g),
     212  owl_select_add_timer("owl_aim_unset_ignorelogin",
     213                       owl_global_get_aim_ignorelogin_timer(&g),
    213214                       0, owl_aim_unset_ignorelogin, NULL, NULL);
    214215
  • commands.c

    r118c919 rc6adf17  
    654654              "show subscriptions / show subs\n"
    655655              "show terminal\n"
     656              "show timers\n"
    656657              "show variables\n"
    657658              "show variable <variable>\n"
     
    22432244  } else if (!strcmp(argv[1], "styles")) {
    22442245    owl_function_show_styles();
     2246  } else if (!strcmp(argv[1], "timers")) {
     2247    owl_function_show_timers();
    22452248  } else if (!strcmp(argv[1], "subs") || !strcmp(argv[1], "subscriptions")) {
    22462249    owl_function_getsubs();
  • functions.c

    r118c919 rc6adf17  
    9090  owl_function_popless_fmtext(&fm);
    9191  owl_list_cleanup(&l, owl_free);
     92  owl_fmtext_cleanup(&fm);
     93}
     94
     95static void _owl_function_timer_append_fmtext(gpointer data, gpointer user_data) {
     96  owl_fmtext *fm = user_data;
     97  owl_timer *timer = data;
     98  char *str = owl_sprintf("- %s: in %d seconds",
     99                          timer->name ? timer->name : "(unnamed)",
     100                          timer->time - time(NULL));
     101  owl_fmtext_append_normal(fm, str);
     102  owl_free(str);
     103  if (timer->interval) {
     104    str = owl_sprintf(", repeat every %d seconds", timer->interval);
     105    owl_fmtext_append_normal(fm, str);
     106    owl_free(str);
     107  }
     108  owl_fmtext_append_normal(fm, "\n");
     109}
     110
     111void owl_function_show_timers(void) {
     112  owl_fmtext fm;
     113  GList **timers;
     114
     115  owl_fmtext_init_null(&fm);
     116  owl_fmtext_append_bold(&fm, "Active timers:\n");
     117
     118  timers = owl_global_get_timerlist(&g);
     119  g_list_foreach(*timers, _owl_function_timer_append_fmtext, &fm);
     120
     121  owl_function_popless_fmtext(&fm);
    92122  owl_fmtext_cleanup(&fm);
    93123}
  • owl.h

    r118c919 rc6adf17  
    532532  void (*destroy)(struct _owl_timer *);
    533533  void *data;
     534  char *name;
    534535} owl_timer;
    535536
  • perl/lib/BarnOwl/Complete/Client.pm

    rdc8f6e0 rc6adf17  
    3737    subs        => undef,
    3838    terminal    => undef,
     39    timers      => undef,
    3940    variables   => undef,
    4041    variable    => \&complete_variable,
  • perl/lib/BarnOwl/MainLoopCompatHook.pm

    r385cce2 rc6adf17  
    4444  unless ($self->{timer}) {
    4545    $self->{timer} = BarnOwl::Timer->new( {
     46        name => "BarnOwl::MainLoopCompatHook",
    4647        after => 0,
    4748        interval => 1,
  • perl/lib/BarnOwl/Timer.pm

    r8d16e58 rc6adf17  
    1313    my $self = {cb => $cb};
    1414
     15    my $name = $args->{name};
     16    $name = "(unnamed)" unless defined $name;
     17
    1518    bless($self, $class);
    1619
    1720    $self->{timer} = BarnOwl::Internal::add_timer($args->{after} || 0,
    1821                                                  $args->{interval} || 0,
    19                                                   $self);
     22                                                  $self,
     23                                                  $name);
    2024    return $self;
    2125}
  • perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm

    rc8d9f84 rc6adf17  
    324324    $self->{reconnect_timer} =
    325325        BarnOwl::Timer->new( {
     326            name  => 'IRC (' . $self->alias . ') reconnect_timer',
    326327            after => $interval,
    327328            cb    => sub {
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/Connection.pm

    r0dbb7d2 rc6adf17  
    198198        $BarnOwl::Module::Jabber::vars{keepAliveTimer} =
    199199            BarnOwl::Timer->new({
     200                'name' => "Jabber ($fullJid) keepAliveTimer",
    200201                'after' => 5,
    201202                'interval' => 5,
  • perl/modules/Twitter/lib/BarnOwl/Module/Twitter/Handle.pm

    rc8d9f84 rc6adf17  
    160160    }
    161161
     162    my $nickname = $self->{cfg}->{account_nickname};
    162163    if($self->{cfg}->{poll_for_tweets}) {
    163164        $self->{timer} = BarnOwl::Timer->new({
     165            name     => "Twitter ($nickname) poll_for_tweets",
    164166            after    => $delay,
    165167            interval => 90,
     
    170172    if($self->{cfg}->{poll_for_dms}) {
    171173        $self->{direct_timer} = BarnOwl::Timer->new({
     174            name     => "Twitter ($nickname) poll_for_dms",
    172175            after    => $delay,
    173176            interval => 180,
  • perlglue.xs

    r818f19c rc6adf17  
    516516
    517517IV
    518 add_timer(after, interval, cb)
     518add_timer(after, interval, cb, name = NULL)
    519519        int after
    520520        int interval
    521521        SV *cb
     522        const char *name
    522523        PREINIT:
    523524                SV *ref;
     
    525526        CODE:
    526527                ref = sv_rvweaken(newSVsv(cb));
    527                 t = owl_select_add_timer(after,
     528                t = owl_select_add_timer(name,
     529                                         after,
    528530                                         interval,
    529531                                         owl_perlconfig_perl_timer,
    530532                                         owl_perlconfig_perl_timer_destroy,
    531533                                         ref);
    532         owl_function_debugmsg("Created timer %p", t);
     534                owl_function_debugmsg("Created timer %s: %p", t->name ? t->name : "(unnamed)", t);
    533535        RETVAL = (IV)t;
    534536        OUTPUT:
     
    542544        CODE:
    543545                t = (owl_timer*)timer;
    544                 owl_function_debugmsg("Freeing timer %p", t);
    545                                 owl_select_remove_timer(t);
     546                owl_function_debugmsg("Freeing timer %s: %p", t->name ? t->name : "(unnamed)", t);
     547                owl_select_remove_timer(t);
    546548
    547549MODULE = BarnOwl                PACKAGE = BarnOwl::Editwin
  • select.c

    r3ecd78b rc6adf17  
    1313}
    1414
    15 owl_timer *owl_select_add_timer(int after, int interval, void (*cb)(owl_timer *, void *), void (*destroy)(owl_timer*), void *data)
     15owl_timer *owl_select_add_timer(const char* name, int after, int interval, void (*cb)(owl_timer *, void *), void (*destroy)(owl_timer*), void *data)
    1616{
    1717  owl_timer *t = owl_malloc(sizeof(owl_timer));
     
    2323  t->destroy = destroy;
    2424  t->data = data;
     25  t->name = name ? owl_strdup(name) : NULL;
    2526
    2627  *timers = g_list_insert_sorted(*timers, t,
     
    3738      t->destroy(t);
    3839    }
     40    owl_free(t->name);
    3941    owl_free(t);
    4042  }
  • variable.c

    rb120bd3 rc6adf17  
    435435      owl_function_zephyr_buddy_check(0);
    436436      if (timer == NULL) {
    437         timer = owl_select_add_timer(180, 180, owl_zephyr_buddycheck_timer, NULL, NULL);
     437        timer = owl_select_add_timer("owl_zephyr_buddycheck_timer",
     438                                     180, 180, owl_zephyr_buddycheck_timer, NULL, NULL);
    438439      }
    439440    } else {
Note: See TracChangeset for help on using the changeset viewer.