diff options
author | hunt <hunt> | 2007-05-16 01:35:46 +0000 |
---|---|---|
committer | hunt <hunt> | 2007-05-16 01:35:46 +0000 |
commit | ca86275918f992eca17e31a311606d7671ac1259 (patch) | |
tree | 140493247bcc6bde8d2a3f66e5f15c70bf000949 | |
parent | cbd6fc7bb15ba9c5d6f7efeb0b239dd503a1b406 (diff) | |
download | systemtap-steved-ca86275918f992eca17e31a311606d7671ac1259.tar.gz systemtap-steved-ca86275918f992eca17e31a311606d7671ac1259.tar.xz systemtap-steved-ca86275918f992eca17e31a311606d7671ac1259.zip |
2007-05-15 Martin Hunt <hunt@redhat.com>
* control.c: Change default buffer number and size.
(_stp_ctl_write): Add debug statements. Check size of
message to avoid overwriting buffer.
-rw-r--r-- | runtime/transport/ChangeLog | 6 | ||||
-rw-r--r-- | runtime/transport/control.c | 17 |
2 files changed, 16 insertions, 7 deletions
diff --git a/runtime/transport/ChangeLog b/runtime/transport/ChangeLog index c0878b9c..49643566 100644 --- a/runtime/transport/ChangeLog +++ b/runtime/transport/ChangeLog @@ -1,3 +1,9 @@ +2007-05-15 Martin Hunt <hunt@redhat.com> + + * control.c: Change default buffer number and size. + (_stp_ctl_write): Add debug statements. Check size of + message to avoid overwriting buffer. + 2007-04-27 Martin Hunt <hunt@redhat.com> * utt.h (struct utt_trace): Remove sequence. diff --git a/runtime/transport/control.c b/runtime/transport/control.c index 443b2302..ec45da06 100644 --- a/runtime/transport/control.c +++ b/runtime/transport/control.c @@ -9,7 +9,7 @@ * later version. */ -#define STP_DEFAULT_BUFFERS 20 +#define STP_DEFAULT_BUFFERS 100 static int _stp_current_buffers = STP_DEFAULT_BUFFERS; static struct list_head _stp_ready_q; @@ -71,7 +71,7 @@ struct _stp_buffer { struct list_head list; int len; int type; - char buf[STP_BUFFER_SIZE]; + char buf[256]; }; static DECLARE_WAIT_QUEUE_HEAD(_stp_ctl_wq); @@ -111,7 +111,7 @@ static void _stp_ctl_write_dbug (int type, void *data, int len) } #endif -static int _stp_ctl_write (int type, void *data, int len) +static int _stp_ctl_write (int type, void *data, unsigned len) { struct _stp_buffer *bptr; unsigned long flags; @@ -120,14 +120,16 @@ static int _stp_ctl_write (int type, void *data, int len) #ifdef DEBUG _stp_ctl_write_dbug(type, data, len); #endif + numtrylock = 0; while (!spin_trylock_irqsave (&_stp_pool_lock, flags) && (++numtrylock < MAXTRYLOCK)) ndelay (TRYLOCKDELAY); - if (unlikely (numtrylock >= MAXTRYLOCK)) + if (unlikely (numtrylock >= MAXTRYLOCK)) return 0; - if (list_empty(&_stp_pool_q)) { + if (unlikely(list_empty(&_stp_pool_q))) { spin_unlock_irqrestore(&_stp_pool_lock, flags); + dbug("_stp_pool_q empty\n"); return -1; } @@ -137,15 +139,16 @@ static int _stp_ctl_write (int type, void *data, int len) spin_unlock_irqrestore(&_stp_pool_lock, flags); bptr->type = type; - memcpy (bptr->buf, data, len); + memcpy(bptr->buf, data, min(len, sizeof(bptr->buf))); bptr->len = len; /* put it on the pool of ready buffers */ numtrylock = 0; while (!spin_trylock_irqsave (&_stp_ready_lock, flags) && (++numtrylock < MAXTRYLOCK)) ndelay (TRYLOCKDELAY); - if (unlikely (numtrylock >= MAXTRYLOCK)) + if (unlikely (numtrylock >= MAXTRYLOCK)) return 0; + list_add_tail(&bptr->list, &_stp_ready_q); spin_unlock_irqrestore(&_stp_ready_lock, flags); |