Skip to content

Commit 7d7870e

Browse files
authored
Merge pull request #107 from chronosphereio/cosmo0920-longer-liveness-of-custom-plugin
cshared: Make longer liveness of custom plugin
2 parents 5572e3e + 868d659 commit 7d7870e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cshared.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ func FLBPluginInit(ptr unsafe.Pointer) int {
133133
}
134134

135135
ctx, cancel := context.WithCancel(context.Background())
136-
defer cancel()
137136

138137
var err error
139138
if theInput != nil {
139+
defer cancel()
140140
conf := &flbInputConfigLoader{ptr: ptr}
141141
cmt, err = input.FLBPluginGetCMetricsContext(ptr)
142142
if err != nil {
@@ -157,6 +157,7 @@ func FLBPluginInit(ptr unsafe.Pointer) int {
157157
}
158158
}
159159
} else if theOutput != nil {
160+
defer cancel()
160161
conf := &flbOutputConfigLoader{ptr: ptr}
161162
cmt, err = output.FLBPluginGetCMetricsContext(ptr)
162163
if err != nil {
@@ -170,6 +171,8 @@ func FLBPluginInit(ptr unsafe.Pointer) int {
170171
}
171172
err = theOutput.Init(ctx, fbit)
172173
} else {
174+
// intended to longer liveness for custom plugin
175+
runCancel = cancel
173176
conf := &flbCustomConfigLoader{ptr: ptr}
174177
logger = &flbCustomLogger{ptr: ptr}
175178
fbit := &Fluentbit{

0 commit comments

Comments
 (0)