@@ -119,17 +119,17 @@ static void json_add_index(struct command *cmd,
119119 json_object_end (response );
120120}
121121
122- u64 wait_index_increment (struct lightningd * ld ,
123- enum wait_subsystem subsystem ,
124- enum wait_index index ,
125- ...)
122+ static u64 wait_index_bump (struct lightningd * ld ,
123+ enum wait_subsystem subsystem ,
124+ enum wait_index index ,
125+ u64 num ,
126+ va_list ap_master )
126127{
127128 struct waiter * i , * n ;
128- va_list ap ;
129129 u64 * idxval = wait_index_ptr (ld , subsystem , index );
130130
131- assert (!add_overflows_u64 (* idxval , 1 ));
132- (* idxval )++ ;
131+ assert (!add_overflows_u64 (* idxval , num ));
132+ (* idxval ) += num ;
133133
134134 /* FIXME: We can optimize this! It's always the max of the fields in
135135 * the table, *unless* we delete one. So we can lazily write this on
@@ -142,6 +142,7 @@ u64 wait_index_increment(struct lightningd *ld,
142142
143143 list_for_each_safe (& ld -> wait_commands , i , n , list ) {
144144 struct json_stream * response ;
145+ va_list ap ;
145146
146147 if (* i -> subsystem != subsystem )
147148 continue ;
@@ -151,7 +152,7 @@ u64 wait_index_increment(struct lightningd *ld,
151152 continue ;
152153
153154 response = json_stream_success (i -> cmd );
154- va_start (ap , index );
155+ va_copy (ap , ap_master );
155156 json_add_index (i -> cmd , response , subsystem , index , * idxval , & ap );
156157 va_end (ap );
157158 /* Delete before freeing */
@@ -162,6 +163,37 @@ u64 wait_index_increment(struct lightningd *ld,
162163 return * idxval ;
163164}
164165
166+ u64 wait_index_increment (struct lightningd * ld ,
167+ enum wait_subsystem subsystem ,
168+ enum wait_index index ,
169+ ...)
170+ {
171+ va_list ap ;
172+ u64 ret ;
173+
174+ va_start (ap , index );
175+ ret = wait_index_bump (ld , subsystem , index , 1 , ap );
176+ va_end (ap );
177+
178+ return ret ;
179+ }
180+
181+ void wait_index_increase (struct lightningd * ld ,
182+ enum wait_subsystem subsystem ,
183+ enum wait_index index ,
184+ u64 num ,
185+ ...)
186+ {
187+ va_list ap ;
188+
189+ if (num == 0 )
190+ return ;
191+
192+ va_start (ap , num );
193+ wait_index_bump (ld , subsystem , index , num , ap );
194+ va_end (ap );
195+ }
196+
165197static struct command_result * param_subsystem (struct command * cmd ,
166198 const char * name ,
167199 const char * buffer ,
0 commit comments