You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by br...@apache.org on 2015/11/10 07:38:47 UTC
trafficserver git commit: TS-4007: ClassAllocator: don't attempt to
destruct the prototype object when ClassAllocator goes out of scope
Repository: trafficserver
Updated Branches:
refs/heads/master c7610467e -> e4cb30531
TS-4007: ClassAllocator: don't attempt to destruct the prototype object when ClassAllocator goes out of scope
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e4cb3053
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e4cb3053
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e4cb3053
Branch: refs/heads/master
Commit: e4cb305315e4969748c9dc8414fd96c8d36b4091
Parents: c761046
Author: Can Selcik <cs...@linkedin.com>
Authored: Mon Nov 9 22:29:37 2015 -0800
Committer: Brian Geffon <br...@apache.org>
Committed: Mon Nov 9 22:38:24 2015 -0800
----------------------------------------------------------------------
lib/ts/Allocator.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e4cb3053/lib/ts/Allocator.h
----------------------------------------------------------------------
diff --git a/lib/ts/Allocator.h b/lib/ts/Allocator.h
index 3b489a7..a21ff90 100644
--- a/lib/ts/Allocator.h
+++ b/lib/ts/Allocator.h
@@ -40,6 +40,7 @@
#ifndef _Allocator_h_
#define _Allocator_h_
+#include <new>
#include <stdlib.h>
#include "ts/ink_queue.h"
#include "ts/ink_defs.h"
@@ -193,11 +194,12 @@ public:
*/
ClassAllocator(const char *name, unsigned int chunk_size = 128, unsigned int alignment = 16)
{
+ ::new ((void*)&proto.typeObject) C();
ink_freelist_init(&this->fl, name, RND16(sizeof(C)), chunk_size, RND16(alignment));
}
struct {
- C typeObject;
+ uint8_t typeObject[sizeof(C)];
int64_t space_holder;
} proto;
};
Re: trafficserver git commit: TS-4007: ClassAllocator: don't attempt to destruct the prototype object when ClassAllocator goes out of scope
Posted by James Peach <jp...@apache.org>.
> On Nov 9, 2015, at 10:38 PM, briang@apache.org wrote:
>
> Repository: trafficserver
> Updated Branches:
> refs/heads/master c7610467e -> e4cb30531
>
>
> TS-4007: ClassAllocator: don't attempt to destruct the prototype object when ClassAllocator goes out of scope
>
>
> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e4cb3053
> Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e4cb3053
> Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e4cb3053
>
> Branch: refs/heads/master
> Commit: e4cb305315e4969748c9dc8414fd96c8d36b4091
> Parents: c761046
> Author: Can Selcik <cs...@linkedin.com>
> Authored: Mon Nov 9 22:29:37 2015 -0800
> Committer: Brian Geffon <br...@apache.org>
> Committed: Mon Nov 9 22:38:24 2015 -0800
>
> ----------------------------------------------------------------------
> lib/ts/Allocator.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e4cb3053/lib/ts/Allocator.h
> ----------------------------------------------------------------------
> diff --git a/lib/ts/Allocator.h b/lib/ts/Allocator.h
> index 3b489a7..a21ff90 100644
> --- a/lib/ts/Allocator.h
> +++ b/lib/ts/Allocator.h
> @@ -40,6 +40,7 @@
> #ifndef _Allocator_h_
> #define _Allocator_h_
>
> +#include <new>
> #include <stdlib.h>
> #include "ts/ink_queue.h"
> #include "ts/ink_defs.h"
> @@ -193,11 +194,12 @@ public:
> */
> ClassAllocator(const char *name, unsigned int chunk_size = 128, unsigned int alignment = 16)
> {
> + ::new ((void*)&proto.typeObject) C();
> ink_freelist_init(&this->fl, name, RND16(sizeof(C)), chunk_size, RND16(alignment));
> }
>
> struct {
> - C typeObject;
> + uint8_t typeObject[sizeof(C)];
I think this should be union'ed to guarantee correct alignment?
> int64_t space_holder;
> } proto;
> };
>
Re: trafficserver git commit: TS-4007: ClassAllocator: don't attempt to destruct the prototype object when ClassAllocator goes out of scope
Posted by James Peach <jp...@apache.org>.
> On Nov 9, 2015, at 10:38 PM, briang@apache.org wrote:
>
> Repository: trafficserver
> Updated Branches:
> refs/heads/master c7610467e -> e4cb30531
>
>
> TS-4007: ClassAllocator: don't attempt to destruct the prototype object when ClassAllocator goes out of scope
>
>
> Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
> Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e4cb3053
> Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e4cb3053
> Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e4cb3053
>
> Branch: refs/heads/master
> Commit: e4cb305315e4969748c9dc8414fd96c8d36b4091
> Parents: c761046
> Author: Can Selcik <cs...@linkedin.com>
> Authored: Mon Nov 9 22:29:37 2015 -0800
> Committer: Brian Geffon <br...@apache.org>
> Committed: Mon Nov 9 22:38:24 2015 -0800
>
> ----------------------------------------------------------------------
> lib/ts/Allocator.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e4cb3053/lib/ts/Allocator.h
> ----------------------------------------------------------------------
> diff --git a/lib/ts/Allocator.h b/lib/ts/Allocator.h
> index 3b489a7..a21ff90 100644
> --- a/lib/ts/Allocator.h
> +++ b/lib/ts/Allocator.h
> @@ -40,6 +40,7 @@
> #ifndef _Allocator_h_
> #define _Allocator_h_
>
> +#include <new>
> #include <stdlib.h>
> #include "ts/ink_queue.h"
> #include "ts/ink_defs.h"
> @@ -193,11 +194,12 @@ public:
> */
> ClassAllocator(const char *name, unsigned int chunk_size = 128, unsigned int alignment = 16)
> {
> + ::new ((void*)&proto.typeObject) C();
> ink_freelist_init(&this->fl, name, RND16(sizeof(C)), chunk_size, RND16(alignment));
> }
>
> struct {
> - C typeObject;
> + uint8_t typeObject[sizeof(C)];
I think this should be union'ed to guarantee correct alignment?
> int64_t space_holder;
> } proto;
> };
>