libpurple/purple-gio.c

changeset 38137
6ea02c2ccb05
parent 37965
b67fb3fb5f85
child 39314
520f77e2ec45
equal deleted inserted replaced
38029:9479ee6b22e2 38137:6ea02c2ccb05
46 return G_SOURCE_CONTINUE; 46 return G_SOURCE_CONTINUE;
47 } 47 }
48 48
49 /* Finally can gracefully close */ 49 /* Finally can gracefully close */
50 50
51 /* Close wrapper input stream, if any */ 51 /* Close input stream, from wrapper or GIOStream */
52 if (data->input != NULL && 52 if (!g_input_stream_close(data->input, NULL, &error)) {
53 !g_input_stream_close(data->input, NULL, &error)) {
54 purple_debug_warning("gio", 53 purple_debug_warning("gio",
55 "Error closing input stream: %s", 54 "Error closing input stream: %s",
56 error->message); 55 error->message);
57 g_clear_error(&error); 56 g_clear_error(&error);
58 } 57 }
59 58
60 g_clear_object(&data->input); 59 g_clear_object(&data->input);
61 60
62 /* Close wrapper output stream, if any */ 61 /* Close output stream, from wrapper or GIOStream */
63 if (data->output != NULL && 62 if (!g_output_stream_close(data->output, NULL, &error)) {
64 !g_output_stream_close(data->output, NULL, &error)) {
65 purple_debug_warning("gio", 63 purple_debug_warning("gio",
66 "Error closing output stream: %s", 64 "Error closing output stream: %s",
67 error->message); 65 error->message);
68 g_clear_error(&error); 66 g_clear_error(&error);
69 } 67 }
95 g_return_if_fail(input == NULL || G_IS_INPUT_STREAM(input)); 93 g_return_if_fail(input == NULL || G_IS_INPUT_STREAM(input));
96 g_return_if_fail(output == NULL || G_IS_OUTPUT_STREAM(output)); 94 g_return_if_fail(output == NULL || G_IS_OUTPUT_STREAM(output));
97 95
98 data = g_new(GracefulCloseData, 1); 96 data = g_new(GracefulCloseData, 1);
99 data->stream = g_object_ref(stream); 97 data->stream = g_object_ref(stream);
98
99 if (input == NULL)
100 input = g_io_stream_get_input_stream(stream);
100 data->input = g_object_ref(input); 101 data->input = g_object_ref(input);
102
103 if (output == NULL)
104 output = g_io_stream_get_output_stream(stream);
101 data->output = g_object_ref(output); 105 data->output = g_object_ref(output);
102 106
103 /* Try gracefully closing the stream synchronously */ 107 /* Try gracefully closing the stream synchronously */
104 if (graceful_close_cb(data) == G_SOURCE_CONTINUE) { 108 if (graceful_close_cb(data) == G_SOURCE_CONTINUE) {
105 /* Has pending operations. Do so asynchronously */ 109 /* Has pending operations. Do so asynchronously */

mercurial