@@ -802,6 +802,17 @@ static struct cio_stream *get_or_create_rejected_stream(struct flb_config *ctx)
802
802
#endif
803
803
}
804
804
805
+ static inline int flb_storage_chunk_restore_state (struct cio_chunk * src , int was_up , int ret_val )
806
+ {
807
+ if (!was_up ) {
808
+ if (cio_chunk_down (src ) != CIO_OK ) {
809
+ flb_debug ("[storage] failed to bring chunk back down" );
810
+ }
811
+ }
812
+
813
+ return ret_val ;
814
+ }
815
+
805
816
int flb_storage_quarantine_chunk (struct flb_config * ctx ,
806
817
struct cio_chunk * src ,
807
818
const char * tag ,
@@ -846,37 +857,30 @@ int flb_storage_quarantine_chunk(struct flb_config *ctx,
846
857
847
858
if (cio_chunk_get_content_copy (src , & buf , & size ) != CIO_OK || size == 0 ) {
848
859
flb_warn ("[storage] cannot read content for DLQ copy (size=%zu)" , size );
849
- return -1 ;
860
+ return flb_storage_chunk_restore_state ( src , was_up , -1 ) ;
850
861
}
851
862
852
863
/* Create + write the DLQ copy */
853
864
dst = cio_chunk_open (ctx -> cio , dlq , name , CIO_OPEN , size , & err );
854
865
if (!dst ) {
855
866
flb_warn ("[storage] DLQ open failed (err=%d)" , err );
856
867
flb_free (buf );
857
- return -1 ;
868
+ return flb_storage_chunk_restore_state ( src , was_up , -1 ) ;
858
869
}
859
870
if (cio_chunk_write (dst , buf , size ) != CIO_OK ||
860
871
cio_chunk_sync (dst ) != CIO_OK ) {
861
872
flb_warn ("[storage] DLQ write/sync failed" );
862
873
cio_chunk_close (dst , CIO_TRUE );
863
874
flb_free (buf );
864
- return -1 ;
875
+ return flb_storage_chunk_restore_state ( src , was_up , -1 ) ;
865
876
}
866
877
867
878
cio_chunk_close (dst , CIO_FALSE );
868
879
flb_free (buf );
869
880
870
881
flb_info ("[storage] quarantined rejected chunk into DLQ stream (bytes=%zu)" , size );
871
882
872
- /* Restore original state if we brought the chunk up */
873
- if (!was_up ) {
874
- if (cio_chunk_down (src ) != CIO_OK ) {
875
- flb_debug ("[storage] failed to bring chunk back down after DLQ copy" );
876
- }
877
- }
878
-
879
- return 0 ;
883
+ return flb_storage_chunk_restore_state (src , was_up , 0 );
880
884
#else
881
885
FLB_UNUSED (ctx );
882
886
FLB_UNUSED (src );
0 commit comments