Total Pageviews

Thursday, 7 September 2017

Linux补丁的制作方法

Linux补丁制作方法,简单明了:
1diff -rNu ngx_output_chain.c ngx_output_chain_dx.c >ngx_output_chain.patch
看一段例子,具体做什么的,你懂的:)
01--- ngx_output_chain.c  2010-10-12 07:06:52.000000000 -0500
02+++ ngx_output_chain_dx.c   2011-11-11 01:48:06.335975441 -0600
03@@ -565,10 +565,31 @@
04         }
05  
06         if (n != size) {
07-            ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0,
08-                          ngx_read_file_n " read only %z of %O from \\"%s\\"",
09-                          n, size, src->file->name.data);
10-            return NGX_ERROR;
11+           int dxcnt=0;
12+           while (dxcnt<5&&n!=size) {
13+               dxcnt++;
14+#if (NGX_HAVE_FILE_AIO)
15+               if (ctx->aio_handler) {
16+                   n = ngx_file_aio_read(src->file, dst->pos, (size_t) size,
17+                                         src->file_pos, ctx->pool);
18+                   if (n == NGX_AGAIN) {
19+                       ctx->aio_handler(ctx, src->file);
20+                       return NGX_AGAIN;
21+                   }
22+               } else {
23+                       n = ngx_read_file(src->file, dst->pos, (size_t) size,
24+                                       src->file_pos);
25+               }
26+#else
27+               n = ngx_read_file(src->file, dst->pos, (size_t) size, src->file_pos);
28+#endif
29+           }
30+           if (n != size) {
31+               ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0,
32+                             ngx_read_file_n " read only %z of %O from \\"%s\\"",
33+                             n, size, src->file->name.data);
34+               return NGX_ERROR;
35+           }
36         }
37  
38         dst->last += n;

No comments:

Post a Comment