Skip to content

Commit a753b89

Browse files
committed
flux-dump: internally use array instead of list
Problem: In the near future we may wish to asynchronously load blobrefs to increase parallelization. This can lead to RPCs responding out of order, so using a list and appending to it will not work for storing responses. Convert from using a msglist to a simple array to store responses.
1 parent bcabc9f commit a753b89

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/cmd/builtin/dump.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static void dump_valref (struct archive *ar,
162162
json_t *treeobj)
163163
{
164164
int count = treeobj_get_count (treeobj);
165-
struct flux_msglist *l;
165+
const flux_msg_t **msgs;
166166
const flux_msg_t *msg;
167167
int total_size = 0;
168168
struct archive_entry *entry;
@@ -183,8 +183,8 @@ static void dump_valref (struct archive *ar,
183183
* retaining the futures for a second pass, just retain references to the
184184
* content.load response messages.
185185
*/
186-
if (!(l = flux_msglist_create ()))
187-
log_err_exit ("could not create message list");
186+
if (!(msgs = calloc (count, sizeof (msg))))
187+
log_err_exit ("could not create messages array");
188188
for (int i = 0; i < count; i++) {
189189
flux_future_t *f;
190190
if (!(f = content_load_byblobref (h,
@@ -197,11 +197,12 @@ static void dump_valref (struct archive *ar,
197197
i,
198198
future_strerror (f, errno));
199199
flux_future_destroy (f);
200-
flux_msglist_destroy (l);
200+
for (int j = 0; j < i; j++)
201+
flux_msg_decref (msgs[j]);
202+
free (msgs);
201203
return;
202204
}
203-
if (flux_msglist_append (l, msg) < 0)
204-
log_err_exit ("could not stash load response message");
205+
msgs[i] = flux_msg_incref (msg);
205206
total_size += len;
206207
flux_future_destroy (f);
207208
}
@@ -217,16 +218,16 @@ static void dump_valref (struct archive *ar,
217218

218219
if (archive_write_header (ar, entry) != ARCHIVE_OK)
219220
log_msg_exit ("%s", archive_error_string (ar));
220-
while ((msg = flux_msglist_pop (l))) {
221-
if (flux_response_decode_raw (msg, NULL, &data, &len) < 0)
221+
for (int i = 0; i < count; i++) {
222+
if (flux_response_decode_raw (msgs[i], NULL, &data, &len) < 0)
222223
log_err_exit ("error processing stashed valref responses");
223224
if (len > 0)
224225
dump_write_data (ar, data, len);
225-
flux_msg_decref (msg);
226+
flux_msg_decref (msgs[i]);
226227
}
227228
archive_entry_free (entry);
228229
progress (h, 1);
229-
flux_msglist_destroy (l);
230+
free (msgs);
230231
}
231232

232233
static void dump_val (struct archive *ar,

0 commit comments

Comments
 (0)