Correctly handle read/write in shared curl