MXS-1953: Always initialize the GWBUF spinlock

The spinlock in the buffer is used but it was not always initialized. Also
added missing initialization of the SERVER pointer.
This commit is contained in:
Markus Mäkelä 2018-07-03 11:32:36 +03:00
parent 013dfa79aa
commit e455e7f15d
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -88,6 +88,7 @@ gwbuf_alloc(unsigned int size)
rval->hint = NULL;
rval->properties = NULL;
rval->gwbuf_type = GWBUF_TYPE_UNDEFINED;
rval->server = NULL;
CHK_GWBUF(rval);
retblock:
if (rval == NULL)
@ -304,6 +305,8 @@ gwbuf_clone_one(GWBUF *buf)
}
atomic_add(&buf->sbuf->refcount, 1);
spinlock_init(&rval->gwbuf_lock);
rval->server = buf->server;
rval->sbuf = buf->sbuf;
rval->start = buf->start;
rval->end = buf->end;
@ -385,6 +388,8 @@ static GWBUF *gwbuf_clone_portion(GWBUF *buf,
return NULL;
}
atomic_add(&buf->sbuf->refcount, 1);
spinlock_init(&clonebuf->gwbuf_lock);
clonebuf->server = buf->server;
clonebuf->sbuf = buf->sbuf;
clonebuf->gwbuf_type = buf->gwbuf_type; /*< clone info bits too */
clonebuf->start = (void *)((char*)buf->start + start_offset);