ccollins476ad opened a new pull request #1234: mgmt/imgmgr: Allow app to reject 
image upload reqs
URL: https://github.com/apache/mynewt-core/pull/1234
 
 
   Allow a callback to configured in the imgmgr module.  If one is configured, 
the callback is called immediately before the request is processed.  The 
callback has the following properties:
   
   ```
   The callback's return code determines whether the upload request is
   accepted or rejected.  If the callback returns 0, processing of the
   upload request proceeds.  If the callback returns nonzero, the request
   is rejected with a response containing an `rc` value equal to the return
   code.
   
   @param offset                The offset specified by the incoming
                                   request.
   @param size                  The total size of the image being uploaded.
   @param arg                   Optional argument specified when the
                                   callback was configured.
   
   @return                      0 if the upload request should be accepted;
                                nonzero to reject the request with the
                                   specified status.
   
   typedef int imgr_upload_fn(uint32_t offset, uint32_t size, void *arg);
   ```
   
   This might be a somewhat painful review; the "clean up" commit introduces a 
lot of changes.  I explain my rationale for these changes in the commit 
message.  I also thought some of image upload code could use a bit of cleanup, 
so I probably changed more than was strictly necessary.  Ignoring the added 
callback feature, the code should be the same as before functionally, with the 
following exceptions:
   
   1. Response status codes changed.  There were a few conditions for which the 
code responded with a `MGMT_ERR_EINVAL` status code, but not because of an 
invalid parameter.  I changed these all to `MGMT_ERR_EUNKNOWN`.
   
   2. The flash area does not stay open for the duration of the upgrade.  Now 
the flash area gets opened each time an image request is received.  I think 
this is the correct behavior.  In the old code, there was a possibility that 
the flash area would remain open indefinitely if an upgrade never completes 
(though I don't know if there are any consequences to this).
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to